Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }