Exemple #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));
        }
Exemple #2
0
        // GET: /Project/Create
        public ActionResult CreateProject()
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var userName                 = HttpContext.User.Identity.Name;
                var currentStageList         = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.CurrentStageRepository.GetAll().ToList <tblCurrentStage>(), "Id", "CurrentStage").ToList();
                var supplierList             = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.SupplierRepository.GetAll().Where(c => c.IUser.ToUpper() != "SYSTEM").ToList <tblSupplier>(), "Id", "SupplierName", isEdit: true).ToList();
                var customerList             = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.CustomerRepository.GetAll().Where(c => c.IUser.ToUpper() != "SYSTEM").ToList <tblCustomer>(), "Id", "CustomerName", isEdit: true).ToList();
                var communicationChannelList = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.CommunicationChannelRepository.GetAll().ToList <tblCommunicationChannel>(), "Id", "CommunicationChannel").ToList();

                var model = new CallReportProjectInfoModel()
                {
                    CreateDate              = DateTime.Now,
                    ddlCurrentStage         = currentStageList,
                    ddlCustomer             = customerList,
                    ddlSupplier             = supplierList,
                    ddlCommunicationChannel = communicationChannelList,
                    SalesPerson             = userName
                };

                return(PartialView("_CreateProject", model));
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
Exemple #3
0
        // GET: /Project/Delete/By ID
        public ActionResult DeleteProject(long id)
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var model = _CallReportInfoService.BMSUnit.CallReportProjectRepository.GetByID(id);

                if (model != null)
                {
                    CallReportProjectInfoModel viewModel = new CallReportProjectInfoModel
                    {
                        Id         = model.Id,
                        SupplierId = model.SupplierId
                    };

                    return(PartialView("_DeleteProject", viewModel));
                }
                else
                {
                    errorViewModel.ErrorMessage = CommonMessage.ErrorOccurred;
                    return(PartialView("_ErrorPopUp", errorViewModel));
                }
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
Exemple #4
0
        // GET: /Project/Edit/By ID
        public ActionResult EditProject(long id)
        {
            var errorViewModel = new ErrorViewModel();

            try
            {
                var model = _CallReportInfoService.BMSUnit.CallReportProjectRepository.GetByID(id);

                var currentStageList         = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.CurrentStageRepository.GetAll().ToList <tblCurrentStage>(), "Id", "CurrentStage").ToList();
                var supplierList             = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.SupplierRepository.GetAll().Where(c => c.IUser.ToUpper() != "SYSTEM").ToList <tblSupplier>(), "Id", "SupplierName", isEdit: true).ToList();
                var customerList             = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.CustomerRepository.GetAll().Where(c => c.IUser.ToUpper() != "SYSTEM").ToList <tblCustomer>(), "Id", "CustomerName", isEdit: true).ToList();
                var communicationChannelList = SelectListItemExtension.PopulateDropdownList(_CallReportInfoService.BMSUnit.CommunicationChannelRepository.GetAll().ToList <tblCommunicationChannel>(), "Id", "CommunicationChannel").ToList();

                if (model != null)
                {
                    CallReportProjectInfoModel viewModel = new CallReportProjectInfoModel
                    {
                        ddlCurrentStage         = currentStageList,
                        ddlCustomer             = customerList,
                        ddlSupplier             = supplierList,
                        ddlCommunicationChannel = communicationChannelList,
                        Id                     = model.Id,
                        CreateDate             = model.CreateDate,
                        ProjectName            = model.ProjectName,
                        CurrentStageId         = model.CurrentStageId,
                        CustomerId             = model.CustomerId,
                        SupplierId             = model.SupplierId,
                        Description            = model.Description,
                        SellingOpportunity     = model.SellingOpportunity,
                        PotVolPerYear          = model.PotVolPerYear,
                        PotAmountPerYear       = model.PotAmountPerYear,
                        RemarkNextAction       = model.RemarkNextAction,
                        CommunicationChannelId = model.CommunicationChannelId,
                        SalesPerson            = model.SalesPerson
                    };

                    //CallReportProjectInfoModel viewModel = new CallReportProjectInfoModel();
                    //viewModel = model.ToModel();

                    return(PartialView("_EditProject", viewModel));
                }
                else
                {
                    errorViewModel.ErrorMessage = CommonMessage.ErrorOccurred;
                    return(PartialView("_ErrorPopUp", errorViewModel));
                }
            }
            catch (Exception ex)
            {
                errorViewModel.ErrorMessage = CommonExceptionMessage.GetExceptionMessage(ex);
                return(PartialView("_ErrorPopUp", errorViewModel));
            }
        }
Exemple #5
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));
        }
 public static tblCallReportProject ToEntity(this CallReportProjectInfoModel model)
 {
     return(Mapper.Map <CallReportProjectInfoModel, tblCallReportProject>(model));
 }