Exemple #1
0
        public ActionResult Create(UpgradeServiceViewModel UpgradeServiceVM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //int Id = (Convert.ToInt32(Session["EditDoctor"]));
                    UpgradeServiceVM.LoginId = Convert.ToInt32(Session["Doctor"]);//Change

                    StringBuilder sb = new StringBuilder();
                    sb.Append("SELECTED SERVICES :- ").AppendLine();
                    foreach (var item in UpgradeServiceVM.membershipListTwo)
                    {
                        if (item.CheckedStatus == true)
                        {
                            //Inserting Values Also in upgradeServiceL  Tabale
                            var NewService = new UpgradeService();
                            sb.Append(item.MembershipType + ", ").AppendLine();
                            NewService.MembershipId   = item.MembershipId;
                            NewService.LoginId        = UpgradeServiceVM.LoginId;//Id;
                            NewService.Durations      = UpgradeServiceVM.DurationId;
                            NewService.AutoRenaval    = UpgradeServiceVM.AutoRenavalId;
                            NewService.CreatedById    = 1;
                            NewService.InactiveFlag   = "N";
                            NewService.CreatedOnDate  = DateTime.Now;
                            NewService.ModifiedById   = 1;
                            NewService.ModifiedOnDate = DateTime.Now;
                            upgradeSerciceRepo.InsertSrvice(NewService);
                            upgradeSerciceRepo.Save();

                            //Inserting Values Also in upgradeServiceLog History Tabale
                            //var NewSerLog = new UpgradeServiceLog();

                            UpgradeServiceLog NewSerLog = new UpgradeServiceLog();


                            NewSerLog.MembershipId   = item.MembershipId;
                            NewSerLog.LoginId        = UpgradeServiceVM.LoginId; //Id;
                            NewSerLog.Durations      = UpgradeServiceVM.DurationId;
                            NewSerLog.AutoRenaval    = UpgradeServiceVM.AutoRenavalId;
                            NewSerLog.CreatedById    = 1;
                            NewSerLog.InactiveFlag   = "N";
                            NewSerLog.CreatedOnDate  = DateTime.Now;
                            NewSerLog.ModifiedById   = 1;
                            NewSerLog.ModifiedOnDate = DateTime.Now;
                            upgradeSerciceRepo.InsertServiceLog(NewSerLog);
                            upgradeSerciceRepo.Save();
                            ViewBag.Message = "Record Successfully Added ..";
                        }
                    }

                    ViewBag.MembershipTwo = sb.ToString();

                    ViewBag.Message = "Record Successfully Added ..";
                }
            }
            catch (Exception)
            {
                //ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator.");
            }
            return(RedirectToAction("Create"));
        }