public void Add(DN_Sale item) { FDIDB.DN_Sale.Add(item); }
public ActionResult Add(string key, int agencyId, Guid userId) { var model = new DN_Sale(); var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); try { var lstproduct = Request["values-arr-product"]; var dateE = Request["DateEnd_"]; var dateS = Request["DateStart_"]; var lstCate = Request["ListCateId"]; UpdateModel(model); model.IsDeleted = false; model.IsShow = true; model.AgencyId = agencyId; model.IsAgency = false; model.UserCreate = userId; model.DateEnd = !string.IsNullOrEmpty(dateE) ? ConvertUtil.ToDateTime(dateE).TotalSeconds() : DateTime.Now.TotalSeconds(); model.DateStart = !string.IsNullOrEmpty(dateS) ? ConvertUtil.ToDateTime(dateS).TotalSeconds() : DateTime.Now.TotalSeconds(); if ((!model.QuantityCode.HasValue || model.QuantityCode == 0) && model.IsAll != true && (!model.TotalOrder.HasValue || model.TotalOrder == 0)) { if (string.IsNullOrEmpty(lstCate)) { model.Categories = _da.GetListCateByArrId(lstCate); model.IsAll = false; } else { if (!string.IsNullOrEmpty(lstproduct)) { var lstInt = FDIUtils.StringToListInt(lstproduct); model.Shop_Product_Detail = _da.GetListIntProductByArrId(lstInt); model.IsAll = false; } } } else { model.IsAll = false; } if (model.IsAll == true) { model.QuantityCode = 0; } if (model.QuantityCode > 0) { model.TotalOrder = 0; } if (model.TotalOrder > 0) { model.QuantityCode = 0; } _da.Add(model); _da.Save(); } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được thêm mới"; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }