static bool CreateAttribute(Product addedProduct, string[] productInfo, string htmlAttrName, string attrName) { if (Array.Find(productInfo, s => s.StartsWith(htmlAttrName)) != null) { var localAttribute = new Domain.Attribute { Name = attrName, Value = Array.Find(productInfo, s => s.StartsWith(htmlAttrName)).Substring(htmlAttrName.Length).Trim() }; var foundAttribute = context.Attributes.Where(a => a.Value == localAttribute.Value && a.Name == localAttribute.Name).FirstOrDefault(); if (foundAttribute == null) { context.Attributes.Add(localAttribute); foundAttribute = localAttribute; } context.ProductsAttributes.Add(new ProductAttribute { Product = addedProduct, Attribute = foundAttribute }); try { context.SaveChanges(); } catch (DbUpdateException) { } return true; } return false; }
private void cboPresetAttributes_SelectedIndexChanged(object sender, EventArgs e) { Domain.Attribute attribute = this._presetAttributes .Where(x => x.Name == (string)this.cboPresetAttributes.SelectedItem) .FirstOrDefault(); this.SetControlValues(attribute); }
void SetControlValues(Domain.Attribute attribute) { if (attribute == null) { return; } this.txtLink.Text = attribute.Link; this.txtDescription.Text = attribute.Description; }
public void UpdateWindow(int rowIndex) { try { int id = int.Parse(this.dGrid.Rows[rowIndex].Cells[AttributeController.ID_INDEX].Value.ToString()); Domain.Attribute attribute = this.View_QueryResults .Where(x => x.Id == id) .FirstOrDefault(); this.lblId.Text = attribute.Id.ToString(); this.txtAttributeName.Text = attribute.Name; this.txtDescription.Text = attribute.Description; this.txtLink.Text = attribute.Link; } catch (ArgumentOutOfRangeException) { /*Skip*/ } catch (Exception ex) { throw ex; } }
private void btnSave_Click(object sender, EventArgs e) { Domain.Attribute attribute = new Domain.Attribute { System_Created = DateTime.Now, }; if (!string.IsNullOrEmpty(this.lblId.Text)) { attribute = this.View_QueryResults .Where(x => x.Id == int.Parse(this.lblId.Text)) .FirstOrDefault(); } attribute.Name = this.txtAttributeName.Text; attribute.Description = this.txtDescription.Text; attribute.Link = this.txtLink.Text; attribute.SystemUpdateDateTime = DateTime.Now; this.View_SaveRecord(attribute); this.View_QueryRecords(null); this.WindowInputChanges(ModifierState.Save); }
private void btnSave_Click(object sender, EventArgs e) { Domain.Attribute attribute = new Domain.Attribute { System_Created = DateTime.Now, }; if (!string.IsNullOrEmpty(this.lblId.Text)) attribute = this.View_QueryResults .Where(x => x.Id == int.Parse(this.lblId.Text)) .FirstOrDefault(); attribute.Name = this.txtAttributeName.Text; attribute.Description = this.txtDescription.Text; attribute.Link = this.txtLink.Text; attribute.SystemUpdateDateTime = DateTime.Now; this.View_SaveRecord(attribute); this.View_QueryRecords(null); this.WindowInputChanges(ModifierState.Save); }