예제 #1
0
        public IActionResult ManageStoreContracts(ManageContractViewModel model)
        {
            model.storeId = GetCurrentUserId().Result;
            var result = _storeManager.SaveContract(model);

            return(View());
        }
예제 #2
0
        public ResponseModel <ManageContractViewModel> SaveContract(ManageContractViewModel model)
        {
            ResponseModel <ManageContractViewModel> response = new ResponseModel <ManageContractViewModel> {
                Data = new ManageContractViewModel()
            };

            try
            {
                var _model = acmContext.StoreContracts.Where(e => e.Id == model.id).FirstOrDefault();
                if (_model != null)
                {
                    _model.CheckInContract  = model.CheckInContract;
                    _model.CheckOutContract = model.CheckOutContract;
                    _model.CreatedOn        = DateTime.Now;
                    _model.StoreId          = model.storeId;
                    acmContext.SaveChanges();
                    response.Status = true;
                }
                else
                {
                    StoreContracts storeModel = new StoreContracts();
                    storeModel.CheckInContract  = model.CheckInContract;
                    storeModel.CheckOutContract = model.CheckOutContract;
                    storeModel.CreatedOn        = DateTime.Now;
                    storeModel.StoreId          = model.storeId;
                    acmContext.Add(storeModel);
                    acmContext.SaveChanges();
                    response.Data   = null;
                    response.Status = true;
                }
            }
            catch (Exception ex)
            {
                response.Data    = null;
                response.Status  = false;
                response.Message = ex.Message;
            }
            return(response);
        }