Щас будет тяжело
This commit is contained in:
parent
cbc5e7f3d7
commit
ac85a743c1
82
Forum/Forum/FormAddTopic.Designer.cs
generated
Normal file
82
Forum/Forum/FormAddTopic.Designer.cs
generated
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
partial class FormAddTopic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.textBoxTopic = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxTopic
|
||||||
|
//
|
||||||
|
this.textBoxTopic.Location = new System.Drawing.Point(20, 12);
|
||||||
|
this.textBoxTopic.Name = "textBoxTopic";
|
||||||
|
this.textBoxTopic.Size = new System.Drawing.Size(218, 27);
|
||||||
|
this.textBoxTopic.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(20, 45);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSave.TabIndex = 1;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(144, 45);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 2;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormAddTopic
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(251, 84);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxTopic);
|
||||||
|
this.Name = "FormAddTopic";
|
||||||
|
this.Text = "Тема";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxTopic;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
20
Forum/Forum/FormAddTopic.cs
Normal file
20
Forum/Forum/FormAddTopic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
public partial class FormAddTopic : Form
|
||||||
|
{
|
||||||
|
public FormAddTopic()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Forum/Forum/FormAddTopic.resx
Normal file
60
Forum/Forum/FormAddTopic.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
126
Forum/Forum/FormAddTopics.Designer.cs
generated
Normal file
126
Forum/Forum/FormAddTopics.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
partial class FormAddTopics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.textBoxCategory = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonChange = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(12, 54);
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView1.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(408, 188);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// textBoxCategory
|
||||||
|
//
|
||||||
|
this.textBoxCategory.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.textBoxCategory.Name = "textBoxCategory";
|
||||||
|
this.textBoxCategory.Size = new System.Drawing.Size(125, 27);
|
||||||
|
this.textBoxCategory.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
this.buttonCreate.Location = new System.Drawing.Point(435, 54);
|
||||||
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
|
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCreate.TabIndex = 2;
|
||||||
|
this.buttonCreate.Text = "Создать";
|
||||||
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
this.buttonChange.Location = new System.Drawing.Point(435, 89);
|
||||||
|
this.buttonChange.Name = "buttonChange";
|
||||||
|
this.buttonChange.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonChange.TabIndex = 3;
|
||||||
|
this.buttonChange.Text = "Изменить";
|
||||||
|
this.buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
this.buttonDelete.Location = new System.Drawing.Point(435, 124);
|
||||||
|
this.buttonDelete.Name = "buttonDelete";
|
||||||
|
this.buttonDelete.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonDelete.TabIndex = 4;
|
||||||
|
this.buttonDelete.Text = "Удалить";
|
||||||
|
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
this.buttonUpdate.Location = new System.Drawing.Point(435, 159);
|
||||||
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
|
this.buttonUpdate.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonUpdate.TabIndex = 5;
|
||||||
|
this.buttonUpdate.Text = "Обновить";
|
||||||
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||||
|
//
|
||||||
|
// FormAddTopic
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(536, 253);
|
||||||
|
this.Controls.Add(this.buttonUpdate);
|
||||||
|
this.Controls.Add(this.buttonDelete);
|
||||||
|
this.Controls.Add(this.buttonChange);
|
||||||
|
this.Controls.Add(this.buttonCreate);
|
||||||
|
this.Controls.Add(this.textBoxCategory);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Name = "FormAddTopic";
|
||||||
|
this.Text = "Добавление тем";
|
||||||
|
this.Load += new System.EventHandler(this.FormAddTopic_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView1;
|
||||||
|
private TextBox textBoxCategory;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
}
|
||||||
|
}
|
78
Forum/Forum/FormAddTopics.cs
Normal file
78
Forum/Forum/FormAddTopics.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using ForumContracts.BusinessLogicContracts;
|
||||||
|
using ForumContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
public partial class FormAddTopics : Form
|
||||||
|
{
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
private readonly ITopicLogic _topicLogic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormAddTopics(ITopicLogic topicLogic, ICategoryLogic categoryLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_topicLogic = topicLogic;
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAddTopic_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _categoryLogic.ReadElement(new CategorySearchModel { Id = _id.Value });
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxCategory.Text = view.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormAddTopic));
|
||||||
|
|
||||||
|
if (service is FormAddTopic form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Forum/Forum/FormAddTopics.resx
Normal file
60
Forum/Forum/FormAddTopics.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
128
Forum/Forum/FormCategories.Designer.cs
generated
Normal file
128
Forum/Forum/FormCategories.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
partial class FormCategories
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonChange = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAddTopicInCategory = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(300, 188);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
this.buttonCreate.Location = new System.Drawing.Point(330, 12);
|
||||||
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
|
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCreate.TabIndex = 1;
|
||||||
|
this.buttonCreate.Text = "Создать";
|
||||||
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
this.buttonChange.Location = new System.Drawing.Point(330, 47);
|
||||||
|
this.buttonChange.Name = "buttonChange";
|
||||||
|
this.buttonChange.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonChange.TabIndex = 2;
|
||||||
|
this.buttonChange.Text = "Изменить";
|
||||||
|
this.buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
this.buttonDelete.Location = new System.Drawing.Point(330, 82);
|
||||||
|
this.buttonDelete.Name = "buttonDelete";
|
||||||
|
this.buttonDelete.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonDelete.TabIndex = 3;
|
||||||
|
this.buttonDelete.Text = "Удалить";
|
||||||
|
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
this.buttonUpdate.Location = new System.Drawing.Point(330, 117);
|
||||||
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
|
this.buttonUpdate.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonUpdate.TabIndex = 4;
|
||||||
|
this.buttonUpdate.Text = "Обновить";
|
||||||
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||||
|
//
|
||||||
|
// buttonAddTopicInCategory
|
||||||
|
//
|
||||||
|
this.buttonAddTopicInCategory.Location = new System.Drawing.Point(330, 152);
|
||||||
|
this.buttonAddTopicInCategory.Name = "buttonAddTopicInCategory";
|
||||||
|
this.buttonAddTopicInCategory.Size = new System.Drawing.Size(94, 54);
|
||||||
|
this.buttonAddTopicInCategory.TabIndex = 5;
|
||||||
|
this.buttonAddTopicInCategory.Text = "Добавить темы";
|
||||||
|
this.buttonAddTopicInCategory.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddTopicInCategory.Click += new System.EventHandler(this.buttonAddTopicInCategory_Click);
|
||||||
|
//
|
||||||
|
// FormCategories
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(438, 211);
|
||||||
|
this.Controls.Add(this.buttonAddTopicInCategory);
|
||||||
|
this.Controls.Add(this.buttonUpdate);
|
||||||
|
this.Controls.Add(this.buttonDelete);
|
||||||
|
this.Controls.Add(this.buttonChange);
|
||||||
|
this.Controls.Add(this.buttonCreate);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormCategories";
|
||||||
|
this.Text = "Категории";
|
||||||
|
this.Load += new System.EventHandler(this.FormCategories_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonAddTopicInCategory;
|
||||||
|
}
|
||||||
|
}
|
129
Forum/Forum/FormCategories.cs
Normal file
129
Forum/Forum/FormCategories.cs
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
using ForumContracts.BindingModels;
|
||||||
|
using ForumContracts.BusinessLogicContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
public partial class FormCategories : Form
|
||||||
|
{
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
public FormCategories(ICategoryLogic categoryLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCategory));
|
||||||
|
|
||||||
|
if (service is FormCategory form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _categoryLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCategories_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_categoryLogic.Delete(new CategoryBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCategory));
|
||||||
|
|
||||||
|
if (service is FormCategory form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddTopicInCategory_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormAddTopics));
|
||||||
|
|
||||||
|
if (service is FormAddTopics form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Forum/Forum/FormCategories.resx
Normal file
60
Forum/Forum/FormCategories.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
85
Forum/Forum/FormCategory.Designer.cs
generated
Normal file
85
Forum/Forum/FormCategory.Designer.cs
generated
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
partial class FormCategory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.textBoxCategory = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxCategory
|
||||||
|
//
|
||||||
|
this.textBoxCategory.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.textBoxCategory.Name = "textBoxCategory";
|
||||||
|
this.textBoxCategory.Size = new System.Drawing.Size(194, 27);
|
||||||
|
this.textBoxCategory.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(12, 45);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSave.TabIndex = 1;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(112, 45);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 2;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// FormCategory
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(222, 82);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxCategory);
|
||||||
|
this.Name = "FormCategory";
|
||||||
|
this.Text = "Категория";
|
||||||
|
this.Click += new System.EventHandler(this.FormCategory_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxCategory;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
88
Forum/Forum/FormCategory.cs
Normal file
88
Forum/Forum/FormCategory.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using ForumContracts.BindingModels;
|
||||||
|
using ForumContracts.BusinessLogicContracts;
|
||||||
|
using ForumContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Forum
|
||||||
|
{
|
||||||
|
public partial class FormCategory : Form
|
||||||
|
{
|
||||||
|
private readonly ICategoryLogic _categoryLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormCategory(ICategoryLogic categoryLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_categoryLogic = categoryLogic;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCategory.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите название роли", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new CategoryBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Name = textBoxCategory.Text
|
||||||
|
};
|
||||||
|
|
||||||
|
var operationResult = _id.HasValue ? _categoryLogic.Update(model) : _categoryLogic.Create(model);
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранеии.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCategory_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _categoryLogic.ReadElement(new CategorySearchModel { Id = _id.Value });
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxCategory.Text = view.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Forum/Forum/FormCategory.resx
Normal file
60
Forum/Forum/FormCategory.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
12
Forum/Forum/FormMain.Designer.cs
generated
12
Forum/Forum/FormMain.Designer.cs
generated
@ -32,6 +32,7 @@
|
|||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.ролиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ролиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.пользователиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.пользователиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.категорииToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -51,7 +52,8 @@
|
|||||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.ролиToolStripMenuItem,
|
this.ролиToolStripMenuItem,
|
||||||
this.пользователиToolStripMenuItem});
|
this.пользователиToolStripMenuItem,
|
||||||
|
this.категорииToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(800, 28);
|
this.menuStrip1.Size = new System.Drawing.Size(800, 28);
|
||||||
@ -72,6 +74,13 @@
|
|||||||
this.пользователиToolStripMenuItem.Text = "Пользователи";
|
this.пользователиToolStripMenuItem.Text = "Пользователи";
|
||||||
this.пользователиToolStripMenuItem.Click += new System.EventHandler(this.пользователиToolStripMenuItem_Click);
|
this.пользователиToolStripMenuItem.Click += new System.EventHandler(this.пользователиToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// категорииToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.категорииToolStripMenuItem.Name = "категорииToolStripMenuItem";
|
||||||
|
this.категорииToolStripMenuItem.Size = new System.Drawing.Size(96, 24);
|
||||||
|
this.категорииToolStripMenuItem.Text = "Категории";
|
||||||
|
this.категорииToolStripMenuItem.Click += new System.EventHandler(this.категорииToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
@ -96,5 +105,6 @@
|
|||||||
private MenuStrip menuStrip1;
|
private MenuStrip menuStrip1;
|
||||||
private ToolStripMenuItem ролиToolStripMenuItem;
|
private ToolStripMenuItem ролиToolStripMenuItem;
|
||||||
private ToolStripMenuItem пользователиToolStripMenuItem;
|
private ToolStripMenuItem пользователиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem категорииToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,5 +26,15 @@ namespace Forum
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void êàòåãîðèèToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCategories));
|
||||||
|
|
||||||
|
if (service is FormCategories form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using ForumContracts.BindingModels;
|
using ForumContracts.BindingModels;
|
||||||
using ForumContracts.BusinessLogicContracts;
|
using ForumContracts.BusinessLogicContracts;
|
||||||
|
using ForumContracts.SearchModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -16,6 +17,9 @@ namespace Forum
|
|||||||
{
|
{
|
||||||
private readonly IUserLogic _userLogic;
|
private readonly IUserLogic _userLogic;
|
||||||
private readonly IRoleLogic _roleLogic;
|
private readonly IRoleLogic _roleLogic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
public FormUser(IRoleLogic roleLogic, IUserLogic userLogic)
|
public FormUser(IRoleLogic roleLogic, IUserLogic userLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -47,14 +51,16 @@ namespace Forum
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _userLogic.Create(new UserBindingModel
|
var model = new UserBindingModel
|
||||||
{
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
Username = textBoxUsername.Text,
|
Username = textBoxUsername.Text,
|
||||||
Email = textBoxLogin.Text,
|
Email = textBoxLogin.Text,
|
||||||
Password = textBoxPassword.Text,
|
Password = textBoxPassword.Text,
|
||||||
RegistrationDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
RegistrationDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
||||||
RoleId = Convert.ToInt32(comboBoxSelectRole.SelectedValue),
|
RoleId = Convert.ToInt32(comboBoxSelectRole.SelectedValue),
|
||||||
});
|
};
|
||||||
|
var operationResult = _id.HasValue ? _userLogic.Update(model) : _userLogic.Create(model);
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при создании пользователя.");
|
throw new Exception("Ошибка при создании пользователя.");
|
||||||
@ -76,6 +82,29 @@ namespace Forum
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void FormUser_Load(object sender, EventArgs e)
|
private void FormUser_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _userLogic.ReadElement(new UserSearchModel { Id = _id.Value });
|
||||||
|
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxLogin.Text = view.Email;
|
||||||
|
textBoxPassword.Text = view.Password;
|
||||||
|
textBoxUsername.Text = view.Username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using ForumContracts.BusinessLogicContracts;
|
using ForumBusinessLogic;
|
||||||
|
using ForumContracts.BindingModels;
|
||||||
|
using ForumContracts.BusinessLogicContracts;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -59,12 +61,48 @@ namespace Forum
|
|||||||
|
|
||||||
private void buttonChange_Click(object sender, EventArgs e)
|
private void buttonChange_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormUser));
|
||||||
|
|
||||||
|
if (service is FormUser form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonDelete_Click(object sender, EventArgs e)
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_userLogic.Delete(new UserBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
@ -44,6 +44,10 @@ namespace Forum
|
|||||||
services.AddTransient<FormRole>();
|
services.AddTransient<FormRole>();
|
||||||
services.AddTransient<FormUsers>();
|
services.AddTransient<FormUsers>();
|
||||||
services.AddTransient<FormUser>();
|
services.AddTransient<FormUser>();
|
||||||
|
services.AddTransient<FormCategories>();
|
||||||
|
services.AddTransient<FormCategory>();
|
||||||
|
services.AddTransient<FormAddTopics>();
|
||||||
|
services.AddTransient<FormAddTopic>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ namespace ForumContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public class TopicSearchModel
|
public class TopicSearchModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ForumContracts.SearchModels;
|
using ForumContracts.SearchModels;
|
||||||
using ForumContracts.StoragesContracts;
|
using ForumContracts.StoragesContracts;
|
||||||
using ForumContracts.ViewModels;
|
using ForumContracts.ViewModels;
|
||||||
|
using ForumDatabase.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -14,32 +15,77 @@ namespace ForumDatabase.Implements
|
|||||||
{
|
{
|
||||||
public CategoryViewModel? Delete(CategoryBindingModel model)
|
public CategoryViewModel? Delete(CategoryBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new ForumDatabase();
|
||||||
|
var element = context.Categories.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Categories.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CategoryViewModel? GetElement(CategorySearchModel model)
|
public CategoryViewModel? GetElement(CategorySearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ForumDatabase();
|
||||||
|
return context.Categories
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.Name) && x.Name ==
|
||||||
|
model.Name) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CategoryViewModel> GetFilteredList(CategorySearchModel model)
|
public List<CategoryViewModel> GetFilteredList(CategorySearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new ForumDatabase();
|
||||||
|
return context.Categories
|
||||||
|
.Where(x => x.Name.Contains(model.Name))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CategoryViewModel> GetFullList()
|
public List<CategoryViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new ForumDatabase();
|
||||||
|
return context.Categories
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CategoryViewModel? Insert(CategoryBindingModel model)
|
public CategoryViewModel? Insert(CategoryBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var newCategory = Category.Create(model);
|
||||||
|
if (newCategory == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ForumDatabase();
|
||||||
|
context.Categories.Add(newCategory);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newCategory.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CategoryViewModel? Update(CategoryBindingModel model)
|
public CategoryViewModel? Update(CategoryBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new ForumDatabase();
|
||||||
|
var component = context.Categories.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ForumContracts.SearchModels;
|
using ForumContracts.SearchModels;
|
||||||
using ForumContracts.StoragesContracts;
|
using ForumContracts.StoragesContracts;
|
||||||
using ForumContracts.ViewModels;
|
using ForumContracts.ViewModels;
|
||||||
|
using ForumDatabase.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -14,32 +15,77 @@ namespace ForumDatabase.Implements
|
|||||||
{
|
{
|
||||||
public TopicViewModel? Delete(TopicBindingModel model)
|
public TopicViewModel? Delete(TopicBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new ForumDatabase();
|
||||||
|
var element = context.Topics.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Topics.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TopicViewModel? GetElement(TopicSearchModel model)
|
public TopicViewModel? GetElement(TopicSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ForumDatabase();
|
||||||
|
return context.Topics
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.Name) && x.Name ==
|
||||||
|
model.Name) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TopicViewModel> GetFilteredList(TopicSearchModel model)
|
public List<TopicViewModel> GetFilteredList(TopicSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new ForumDatabase();
|
||||||
|
return context.Topics
|
||||||
|
.Where(x => x.Name.Contains(model.Name))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TopicViewModel> GetFullList()
|
public List<TopicViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new ForumDatabase();
|
||||||
|
return context.Topics
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TopicViewModel? Insert(TopicBindingModel model)
|
public TopicViewModel? Insert(TopicBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var newTopic = Topic.Create(model);
|
||||||
|
if (newTopic == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ForumDatabase();
|
||||||
|
context.Topics.Add(newTopic);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newTopic.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TopicViewModel? Update(TopicBindingModel model)
|
public TopicViewModel? Update(TopicBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new ForumDatabase();
|
||||||
|
var component = context.Topics.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user