public JsonResult SaveSellsPoint(VM_SellsPoint aSellsPoint) { if (ModelState.IsValid) { try { tblSellsPoint sellsPoint = new tblSellsPoint(); sellsPoint.SellsPointName = aSellsPoint.SellsPointName; sellsPoint.SellsPointStoreId = aSellsPoint.SellsPointStoreId; sellsPoint.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); sellsPoint.CreatedBy = SessionManger.LoggedInUser(Session); sellsPoint.CreatedDateTime = DateTime.Now; sellsPoint.EditedBy = null; sellsPoint.EditedDateTime = null; unitOfWork.SellsPointRepository.Insert(sellsPoint); unitOfWork.Save(); tblStoreInformation aStoreInformation = unitOfWork.StoreRepository.GetByID(sellsPoint.SellsPointStoreId); aStoreInformation.SellsPointStoreId = sellsPoint.SellsPointId; unitOfWork.StoreRepository.Update(aStoreInformation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Sells point added successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateSellsPoint(VM_SellsPoint aSellsPoint) { tblSellsPoint sellsPoint = unitOfWork.SellsPointRepository.GetByID(aSellsPoint.SellsPointId); sellsPoint.SellsPointId = aSellsPoint.SellsPointId; sellsPoint.SellsPointName = aSellsPoint.SellsPointName; sellsPoint.SellsPointStoreId = aSellsPoint.SellsPointStoreId; sellsPoint.EditedBy = SessionManger.LoggedInUser(Session); sellsPoint.EditedDateTime = DateTime.Now; try { //Update previous StoreInformation SellsPointStoreId tblStoreInformation bStoreInformation = unitOfWork.StoreRepository.Get().Where(a => a.SellsPointStoreId == sellsPoint.SellsPointId).FirstOrDefault(); bStoreInformation.SellsPointStoreId = null; unitOfWork.StoreRepository.Update(bStoreInformation); //Update Present StoreInformation SellsPointStoreId tblStoreInformation aStoreInformation = unitOfWork.StoreRepository.GetByID(sellsPoint.SellsPointStoreId); aStoreInformation.SellsPointStoreId = sellsPoint.SellsPointId; unitOfWork.StoreRepository.Update(aStoreInformation); //Update SellsPointRepository unitOfWork.SellsPointRepository.Update(sellsPoint); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Sells Point Edited Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddProductToProductionHouse(List <Vm_ProductTransfetToProductionHouse> ProductList) { try { tblStoreInformation mainStore = null; tblProductTransfer productTransfer = null; foreach (var productTransfetToProductionHouse in ProductList) { if (productTransfetToProductionHouse.Quantity != null) { productTransfer = new tblProductTransfer(); productTransfer.DateTime = DateTime.Now; productTransfer.CreatedBy = SessionManger.LoggedInUser(Session); productTransfer.EditedBy = null; productTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); productTransfer.CreatedDateTime = DateTime.Now; productTransfer.StoreId = productTransfetToProductionHouse.StoreId; productTransfer.SupplierId = null; productTransfer.ProductId = productTransfetToProductionHouse.ProductId; productTransfer.Quantity = productTransfetToProductionHouse.Quantity; productTransfer.TransferDate = DateTime.Now; productTransfer.isIn = true; productTransfer.Unit = productTransfetToProductionHouse.Unit; unitOfWork.ProductTransferRepository.Insert(productTransfer); unitOfWork.Save(); //--------- Get Main Store of --> Own Store--------------- mainStore = unitOfWork.StoreRepository.GetByID(productTransfer.StoreId); //----------------- Out Product to Main Store ------------ tblProductTransfer productTransfer2 = new tblProductTransfer(); productTransfer2.StoreId = mainStore.ParentStoreId; productTransfer2.SupplierId = null; productTransfer2.ProductId = productTransfetToProductionHouse.ProductId; productTransfer2.Quantity = productTransfetToProductionHouse.Quantity; productTransfer2.TransferDate = DateTime.Now; productTransfer2.Unit = productTransfetToProductionHouse.Unit; productTransfer2.isOut = true; productTransfer2.CreatedDateTime = DateTime.Now; unitOfWork.ProductTransferRepository.Insert(productTransfer2); productTransfer2.DateTime = DateTime.Now; productTransfer2.CreatedBy = SessionManger.LoggedInUser(Session); productTransfer2.EditedBy = null; productTransfer2.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); unitOfWork.Save(); } } ProductToProductionHouseReport(Convert.ToInt32(mainStore.ParentStoreId), Convert.ToInt32(productTransfer.StoreId), ProductList); //----------- In a Product to Own Store------------------ return(Json(new { success = true, successMessage = "Product Transfer to Product House Successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddStore(tblStoreInformation _store) { try { unitOfWork.StoreRepository.Insert(_store); unitOfWork.Save(); return(Json(new { success = true, successMessage = " Successfully Added" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { throw; } }
public JsonResult EditStoreById(tblStoreInformation store) { try { unitOfWork.StoreRepository.Update(store); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Successfully Edited" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAllOwnStore() { try { var productionHouseInfoList = new List <tblStoreInformation>(); var mainStore = (from a in unitOfWork.StoreRepository.Get() where a.isProductionHouseStore == true select a).ToList(); foreach (var a in mainStore) { var store = new tblStoreInformation(); store.store_name = a.store_name; store.store_id = a.store_id; productionHouseInfoList.Add(store); } return(Json(new { result = productionHouseInfoList, success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteSellsPoint(int?id) { try { tblSellsPoint sellsPoint = unitOfWork.SellsPointRepository.GetByID(id); if (sellsPoint == null) { return(Json(new { success = false, errorMessage = "Sells Point Delete Failed" }, JsonRequestBehavior.AllowGet)); } tblStoreInformation aStoreInformation = unitOfWork.StoreRepository.GetByID(sellsPoint.SellsPointStoreId); aStoreInformation.SellsPointStoreId = null; unitOfWork.StoreRepository.Update(aStoreInformation); unitOfWork.SellsPointRepository.Delete(sellsPoint); unitOfWork.Save(); return(Json(new { success = true, message = "Sells Point Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }