コード例 #1
0
 public bool DeletePlan(PlanVm plan)
 {
     if (plan != null)
     {
         //get the service using the id
         Plan planMd = _session.QueryOver <Plan>().Where(x => x.Id == plan.Id).SingleOrDefault();
         //update the plan
         planMd.IsDeleted = true;
         _session.Transact(session => session.Update(planMd));
     }
     return(true);
 }
コード例 #2
0
        public PlanVm GetPlan(int id)
        {
            Plan planMd = _session.QueryOver <Plan>().Where(x => x.Id == id).SingleOrDefault();

            if (planMd != null)
            {
                PlanVm planVmm = (PlanVm)AutoMapperConfig.ConfigurationFile.ConvertPlan(planMd, typeof(PlanVm));
                return(planVmm);
            }
            return(null);

            //var mapper = AutoMapperConfig.ConfigurationFile.Config2.CreateMapper();
            //var res= mapper.Map<PlanVm>(planMd);
        }
コード例 #3
0
        public bool AddnewPlan(PlanVm service)
        {
            //Add date Added

            Plan planMd = new Plan()
            {
                Name        = service.Name,
                Code        = service.Code,
                Description = service.Description,
                Status      = service.Status,
                CreatedBy   = CurrentRequestData.CurrentUser.Guid.ToString(),
                CreatedOn   = DateTime.Now,
            };

            _session.Transact(session => session.Save(planMd));
            return(true);
        }
コード例 #4
0
 public ActionResult Delete(PlanVm plan)
 {
     if (plan.Id > 0)
     {
         bool response = _planService.DeletePlan(plan);
         if (response)
         {
             _pageMessageSvc.SetSuccessMessage(string.Format("Plan [{0}] was deleted successfully.", plan.Name.ToUpper()));
         }
         else
         {
             _pageMessageSvc.SetErrormessage(string.Format("There was an error deleting plan [{0}] ",
                                                           plan.Name.ToUpper()));
         }
     }
     return(_uniquePageService.RedirectTo <PlanPage>());
 }
コード例 #5
0
        public bool UpdatePlan(PlanVm plan)
        {
            Plan planMd = _session.QueryOver <Plan>().Where(x => x.Id == plan.Id).SingleOrDefault();

            if (planMd != null)
            {
                planMd.Name        = plan.Name;
                planMd.Code        = plan.Code;
                planMd.Description = plan.Description;
                planMd.Status      = plan.Status;

                _session.Transact(session => session.Update(planMd));
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
ファイル: AutoMapperConfig.cs プロジェクト: infotechub/cbtch
            public static object ConvertPlan(object input, Type output)
            {
                if (input.GetType() == typeof(Plan) && output == typeof(PlanVm))
                {
                    //conver to View model from entity model
                    Plan   inpuT = (Plan)input;
                    PlanVm vm    = new PlanVm()
                    {
                        Id          = inpuT.Id,
                        Name        = inpuT.Name,
                        Code        = inpuT.Code,
                        Description = inpuT.Description,
                        Status      = inpuT.Status,
                        CreatedOn   = inpuT.CreatedOn,
                    };

                    return(vm);
                }
                else if (input.GetType() == typeof(PlanVm) && output == typeof(Plan))
                {
                    PlanVm inpuT = (PlanVm)input;
                    Plan   md    = new Plan()
                    {
                        Id          = inpuT.Id,
                        Name        = inpuT.Name,
                        Code        = inpuT.Code,
                        Description = inpuT.Description,
                        Status      = inpuT.Status,
                        CreatedOn   = inpuT.CreatedOn
                    };

                    return(md);
                }
                else
                {
                    return(null);
                }
            }
コード例 #7
0
        public ActionResult Add(PlanVm plan)
        {
            //set the created user
            bool response = _planService.AddnewPlan(plan);

            if (response)
            {
                //successfule
                //Set the success message for user to see
                _pageMessageSvc.SetSuccessMessage(string.Format("Plan [{0}] was added successfully.", plan.Name.ToUpper()));
                //Session["PageSuccessMessage"] = string.Format("Service [{0}] was added successfully.", services.Name.ToUpper());
            }
            else
            {
                //there was an error
                //Set the Error message for user to see
                //Session["PageErrorMessage"] = string.Format("There was an error adding service [{0}] ", services.Name.ToUpper());
                _pageMessageSvc.SetErrormessage(string.Format("There was an error adding plan [{0}] ",
                                                              plan.Name.ToUpper()));
            }

            return(_uniquePageService.RedirectTo <PlanPage>());
        }
コード例 #8
0
        public ActionResult Delete(int id)
        {
            PlanVm item = _planService.GetPlan(id);

            return(PartialView("DeletePlan", item));
        }
コード例 #9
0
 public ActionResult Edit(PlanVm plan)
 {
     _planService.UpdatePlan(plan);
     return(_uniquePageService.RedirectTo <PlanPage>());
 }
コード例 #10
0
        public ActionResult Edit(int id)
        {
            PlanVm plan = _planService.GetPlan(id);

            return(PartialView("EditPlan", plan));
        }