public ActionResult Add() { string name = Request.Form["proT"]; if (string.IsNullOrEmpty(name)) { return(Content(ReturnMsg.empty.ToString())); } ProductViewModel model = LitJson.JsonMapper.ToObject <ProductViewModel>(name); if (model == null) { return(Content(ReturnMsg.fail.ToString())); } model.AddedTime = DateTime.Now; model.UpdateTime = DateTime.Now; bool isSucc = BProduct.Insert(model); if (isSucc) { return(Content(ReturnMsg.success.ToString())); } else { return(Content(ReturnMsg.fail.ToString())); } }
private void btnSave_Click(object sender, EventArgs e) { try { string resp = ""; if (txtNameConfig.Text == string.Empty || txtidcategory.Text == string.Empty || txtCode.Text == string.Empty) { MessageError("Fill the fields"); errorIcon.SetError(txtNameConfig, "Insert the name"); errorIcon.SetError(txtidcategory, "Insert the category id"); errorIcon.SetError(txtCode, "Insert the code"); } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(); this.pxImage.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] image = ms.GetBuffer(); if (this.eNew) { resp = BProduct.Insert(this.txtCode.Text, this.txtNameConfig.Text, this.txtDescription.Text, image, Convert.ToInt32(this.txtidcategory.Text), Convert.ToInt32(this.cbPresentation.SelectedValue)); } else { resp = BProduct.Edit(Convert.ToInt32(this.txtIdProduct.Text), this.txtCode.Text, this.txtNameConfig.Text, this.txtDescription.Text, image, Convert.ToInt32(this.txtidcategory.Text), Convert.ToInt32(this.cbPresentation.SelectedValue)); } if (resp.Equals("OK")) { if (this.eNew) { this.MessageOk("Register saved"); } else { this.MessageOk("Register Edited"); } } else { this.MessageError(resp); } this.eNew = false; this.eEdit = false; this.Enabledbuttons(); this.Clean(); this.ShowValues(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
public void Select() { bool result = false; TransactionScope ts = new TransactionScope(); EProduct eProduct = new EProduct(); EProduct insertedProduct = new EProduct(); BProduct bProduct = new BProduct(); eProduct.DescriptionForSale = Aleatory.GetString(60); eProduct.DescriptionForStore = Aleatory.GetString(60); eProduct.Audit.UserRegister = Aleatory.GetString(8); insertedProduct = bProduct.Insert(eProduct); if (insertedProduct != null) { result = true; } Assert.IsTrue(result); }