public JsonResult AjaxTypeUpdate(string row, int formulationID, int extruderID) { TPO.Web.Core.ResponseMessage responseMessage; try { TPOFormulationRawMaterialModel formulation = JsonConvert.DeserializeObject <TPOFormulationRawMaterialModel>(row); if (formulation != null) { formulation.LastModified = DateTime.Now; TPOFormulationRawMaterialDto dto = new TPOFormulationRawMaterialDto(); using (TPOFormulationRawMaterialService service = new TPOFormulationRawMaterialService()) { Mapper.Map(formulation, dto); dto.PlantID = CurrentPlantId; dto.TPOFormulationID = formulationID; dto.TPOExtruderID = extruderID; using (RawMaterialService rawMaterialService = new RawMaterialService()) { dto.RawMaterialCode = rawMaterialService.Get(formulation.RawMaterialID).Code; } if (formulation.ID > 0) { service.Update(dto); } else { service.Add(dto); } } } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } return(Json(responseMessage, JsonRequestBehavior.AllowGet)); }
public JsonResult GridByType(int lineID, int?rows, int?page) { rows = rows ?? DefaultPageSize; page = page ?? DefaultPage; int lineDescription; List <CurrentScrimViewModel> list = new List <CurrentScrimViewModel>(); List <TPOCurrentRawMaterialDto> materialslist = new List <TPOCurrentRawMaterialDto>(); if (lineID != null) { using (var service = new ProductionLineService()) { lineDescription = service.Get(lineID).ID; } using (var service = new TPOCurrentRawMaterialService()) { materialslist = service.GetAll().Where(q => q.LineID == lineDescription).ToList(); } foreach (var dto in materialslist) { RawMaterialReceivedDto rawMaterialReceivedDto = new RawMaterialReceivedDto(); RawMaterialDto rawMaterialDto = new RawMaterialDto(); CurrentScrimViewModel csvm = new CurrentScrimViewModel(); csvm.Id = dto.ID; csvm.PlantId = CurrentPlantId; using (var service = new RawMaterialReceivedService()) { rawMaterialReceivedDto = service.Get(dto.RawMaterialReceivedID ?? 0); csvm.LotNumber = rawMaterialReceivedDto.LotNumber; csvm.RawMaterialID = rawMaterialReceivedDto.Id; } using (var service = new RawMaterialService()) { rawMaterialDto = service.Get(Convert.ToInt32(rawMaterialReceivedDto.RawMaterialId)); csvm.RawMaterialCode = rawMaterialDto.Code; } csvm.EnteredBy = dto.EnteredBy; csvm.ModifiedBy = dto.ModifiedBy; csvm.DateEntered = dto.DateEntered; csvm.LastModified = dto.LastModified; list.Add(csvm); } } int total; total = list.Count(); List <CurrentScrimViewModel> currentPageDtos = new List <CurrentScrimViewModel>(); if (rows.HasValue) { currentPageDtos.AddRange(list.OrderByDescending(r => r.DateEntered).Skip((page.Value - 1) * rows.Value).Take(rows.Value).ToList()); } else { currentPageDtos.AddRange(list); } return(BuildJsonResult(currentPageDtos, total)); }