Beispiel #1
0
        public ActionResult CreateProject(CallReportProjectInfoModel viewModel)
        {
            var strMessage = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    #region Current User

                    var userName = HttpContext.User.Identity.Name;
                    viewModel.IUser = userName;
                    viewModel.IDate = DateTime.Now;
                    viewModel.EDate = DateTime.Now;

                    #endregion

                    var entity = viewModel.ToEntity();
                    _CallReportInfoService.BMSUnit.CallReportProjectRepository.Add(entity);
                    _CallReportInfoService.BMSUnit.CallReportProjectRepository.SaveChanges();

                    return(Content(Boolean.TrueString));
                    //return Content("Information has been saved successfully");
                }

                strMessage = Common.GetModelStateErrorMessage(ModelState);
            }
            catch (Exception ex)
            {
                strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Save);
            }

            return(Content(strMessage));
        }
Beispiel #2
0
        public ActionResult EditProject(CallReportProjectInfoModel viewModel)
        {
            var strMessage = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    var model = _CallReportInfoService.BMSUnit.CallReportProjectRepository.GetByID(viewModel.Id);

                    #region Current User

                    viewModel.IUser = model.IUser;
                    viewModel.IDate = model.IDate;

                    var userName = HttpContext.User.Identity.Name;
                    viewModel.EUser = userName;
                    viewModel.EDate = DateTime.Now;

                    #endregion

                    var entity = viewModel.ToEntity();

                    _CallReportInfoService.BMSUnit.CallReportProjectRepository.Update(entity);
                    _CallReportInfoService.BMSUnit.CallReportProjectRepository.SaveChanges();

                    return(Content(Boolean.TrueString));
                }

                strMessage = Common.GetModelStateErrorMessage(ModelState);
            }
            catch (Exception ex)
            {
                strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Update);
            }

            return(Content(strMessage));
        }