Exemplo n.º 1
0
        private RationViewModel BindRationViewModel(Ration ration)
        {
            var userPref = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference;
            if (ration == null) return null;
            var rationViewModel = new RationViewModel();
            rationViewModel.RationID = ration.RationID;
            rationViewModel.IsDefaultRation = ration.IsDefaultRation;
            rationViewModel.CreatedBy = ration.CreatedBy;

            rationViewModel.CreatedDate = ration.CreatedDate;
            rationViewModel.UpdatedBy = ration.UpdatedBy;
            rationViewModel.UpdatedDate = ration.UpdatedDate;
            rationViewModel.ReferenceNumber = ration.RefrenceNumber;
            //rationViewModel.CreatedDateEC = ration.CreatedDate.HasValue
            //                                    ? EthiopianDate.GregorianToEthiopian(ration.CreatedDate.Value)
            //                                    : "";
            rationViewModel.UpdatedDateEC = ration.UpdatedDate.HasValue
                                     ? EthiopianDate.GregorianToEthiopian(ration.UpdatedDate.Value)
                                     : "";
            rationViewModel.DateCreated = ration.CreatedDate.ToCTSPreferedDateFormat(userPref);// RequistionDate.ToCTSPreferedDateFormat(UserAccountHelper.UserCalendarPreference());
            return rationViewModel;
        }
Exemplo n.º 2
0
        public ActionResult Edit(RationViewModel rationViewModel)
        {
            if (rationViewModel != null && ModelState.IsValid)
            {
                try
                {

                    var orign = _rationService.FindById(rationViewModel.RationID);
                    orign.IsDefaultRation = rationViewModel.IsDefaultRation;

                    orign.UpdatedBy = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID;
                    orign.UpdatedDate = DateTime.Today;
                    _rationService.EditRation(orign);
                    return Json(new { success = true });
                }
                catch (Exception ex)
                {
                    var log = new Logger();
                    log.LogAllErrorsMesseges(ex,_log);
                    ModelState.AddModelError("Errors", ex.Message);
                }
            }
            return PartialView("_Edit", rationViewModel);
        }