public ActionResult Create(string num = null) { OnlinePurchaseProductDto onlineDto = new OnlinePurchaseProductDto(); DateTime current = DateTime.Now; string strDate = current.ToString("yyyy-MM-dd 00:00:00"); string strEndDate = current.ToString("yyyy-MM-dd 23:23:59"); onlineDto.StartDate = DateTime.Parse(strDate); onlineDto.EndDate = DateTime.Parse(strEndDate); int Quantity = 0; if (num != null) { OnlinePurchaseProduct online = _onlinePurchaseProductContract.OnlinePurchaseProducts.FirstOrDefault(x => x.IsDeleted == false && x.IsEnabled == true && x.UniqueCode == num); if (online != null) { Quantity = online.OnlinePurchaseProductItems.Where(w => w.IsEnabled && !w.IsDeleted).Count(); Mapper.CreateMap <OnlinePurchaseProduct, OnlinePurchaseProductDto>(); onlineDto = Mapper.Map <OnlinePurchaseProduct, OnlinePurchaseProductDto>(online); CheckResultEdo edo = new CheckResultEdo(); edo.UniqueCode = onlineDto.UniqueCode; edo.ValidCount = Quantity; WriteCookie(edo); } } ViewBag.Quantity = Quantity; return(View(onlineDto)); }
public JsonResult Create(OnlinePurchaseProductDto dto) { dto.EndDate = dto.EndDate.AddHours(23).AddMinutes(59).AddSeconds(59); OperationResult oper = _onlinePurchaseProductContract.Insert(dto); if (oper.ResultType == OperationResultType.Success) { CheckResultEdo edo = new CheckResultEdo(); edo.UniqueCode = dto.UniqueCode; WriteCookie(edo); } return(Json(oper)); }