public static JsonResult Add(DetailInfoViewModel detailInfoViewModel) { JsonResult jsonResult = new JsonResult(); try { if (detailInfoViewModel.CustomerId != 0 && detailInfoViewModel.ItemSizeId != 0 && detailInfoViewModel.Quantity != 0) { jsonResult.msg = Boolean.TrueString; jsonResult.status = MessageType.success.ToString(); return jsonResult; } jsonResult.msg = "Data is required"; jsonResult.status = MessageType.info.ToString(); return jsonResult; } catch (Exception ex) { jsonResult.msg = ExceptionHelper.ExceptionMessageFormat(ex); jsonResult.status = MessageType.error.ToString(); return jsonResult; } }
public static JsonResult AjaxSave(MasterDetailInfoViewModel model, List<DetailInfoViewModel> modelList) { JsonResult jsonResult = new JsonResult(); try { if (model.CustomerId != 0 && model.CustomerName != null && model.Address != null) { if (model != null) { if (modelList.Any()) { //Save MasterDetails Data MasterDetailInfoModel masterDetailInfoModel = new MasterDetailInfoModel() { CustomerID = model.CustomerId, CustomerName = model.CustomerName, Address = model.Address, LoadDate = DateTime.Now }; List<DetailInfoModel> detailInfoModelList = new List<DetailInfoModel>(); ////Master Data Insert //if (InsertToMasterDetailInfo(masterDetailInfoModel) > 0) //{ //var lastInsetMasterDetailInfo = _db.tbl_MasterDetailInfo.FirstOrDefault(x => x.CustomerID == model.CustomerId && x.CustomerName == model.CustomerName); ////Details Data Insert //if (lastInsetMasterDetailInfo != null) //{ foreach (var item in modelList) { DetailInfoModel detailInfoModel = new DetailInfoModel() { //CustomerID = model.CustomerId, ItemSizeID = item.ItemSizeId, Quantity = item.Quantity }; //if (InsertToDetailInfo(detailInfoModel) > 0) //{ // continue; //} //else //{ // break; //} detailInfoModelList.Add(detailInfoModel); } //} //} //Save MasterDetails Data if (InsertMasterDetailInfoBySP(masterDetailInfoModel, detailInfoModelList)) { jsonResult.msg = "Data saved successfully to server."; jsonResult.status = MessageType.success.ToString(); return jsonResult; } else { jsonResult.msg = "Data can not saved successfully to server."; jsonResult.status = MessageType.warn.ToString(); return jsonResult; } } else { //Details Data Null Message jsonResult.msg = "Details data could not found."; jsonResult.status = MessageType.warn.ToString(); return jsonResult; } } else { //Master Data Null Message jsonResult.msg = "Master data could not found."; jsonResult.status = MessageType.warn.ToString(); return jsonResult; } } jsonResult.msg = "Data is required"; jsonResult.status = MessageType.info.ToString(); return jsonResult; } catch (Exception ex) { jsonResult.msg = ExceptionHelper.ExceptionMessageFormat(ex); jsonResult.status = MessageType.error.ToString(); return jsonResult; } }
public static JsonResult OfflineAjaxSave(List<OfflineMasterDetailViewModel> offlineModelList) { JsonResult jsonResult = new JsonResult(); try { if (offlineModelList != null) { foreach (var offlineMasterDetailViewModel in offlineModelList) { if (offlineMasterDetailViewModel.Details.Any()) { //Save MasterDetails Data //Save MasterDetails Data jsonResult.msg = "Data saved successfully to server."; jsonResult.status = MessageType.success.ToString(); return jsonResult; } else { //Details Data Null Message jsonResult.msg = "Details data could not found."; jsonResult.status = MessageType.warn.ToString(); return jsonResult; } } } //Data Null Message jsonResult.msg = "Data could not found."; jsonResult.status = MessageType.warn.ToString(); return jsonResult; } catch (Exception ex) { jsonResult.msg = ExceptionHelper.ExceptionMessageFormat(ex); jsonResult.status = MessageType.error.ToString(); return jsonResult; } }