Example #1
0
        public ActionResult Create(CityMaster citymaster)
        {
            if (ModelState.IsValid)
            {
                db.CityMasters.Add(citymaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(citymaster));
        }
Example #2
0
        public ActionResult savedata(VendorContactInfo obj, string Save, string Viewshow, int[] chkvendors)
        {
            #region ##############SAVE##############
            if (!string.IsNullOrEmpty(Save))
            {
                var VendorContactName = obj.VendorContactName;
                var checkduplicacy    = (from x in db.VendorContactInfoes
                                         where x.VendorContactName == VendorContactName && x.VendorContactNo == obj.VendorContactNo
                                         select x
                                         ).ToList();

                if (ModelState.IsValid)
                {
                    if (checkduplicacy.Count > 0)
                    {
                        ViewBag.Statelists = SelectListItem();
                        TempData["alert"]  = "0";
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        db.VendorContactInfoes.Add(obj);
                        db.SaveChanges();
                        TempData["alert"] = "1";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    string messages = string.Join("; ", ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                }
            }
            #endregion

            #region #########BulkSave###############
            if (!string.IsNullOrEmpty(Viewshow))
            {
            }
            #endregion
            return(RedirectToAction("Index")); // call pageload
        }
        public ActionResult savedata(DepartmentMaster obj, string Save, string Viewshow, string Update)
        {
            #region ##############SAVE##############
            if (!string.IsNullOrEmpty(Save))
            {
                var DepartmentName = obj.DeptName;
                var checkduplicacy = (from x in db.DepartmentMasters
                                      where x.DeptName == DepartmentName && x.DeptState == obj.DeptState
                                      select x
                                      ).ToList();

                if (ModelState.IsValid)
                {
                    if (checkduplicacy.Count > 0)
                    {
                        ViewBag.Statelists = SelectListItem();
                        TempData["alert"]  = "0";
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        db.DepartmentMasters.Add(obj);
                        db.SaveChanges();
                        TempData["alert"] = "1";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    string messages = string.Join("; ", ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                }
            }
            #endregion

            #region #########SHOW###############
            if (!string.IsNullOrEmpty(Viewshow))
            {
                ViewBag.Statelists = SelectListItem();

                ViewBag.DeptName = (from s in db.DepartmentMasters
                                    join sa in db.StateMasters on s.DeptState equals sa.StateId
                                    where s.DeptState == obj.DeptState
                                    select new CommonViewClass
                {
                    DeptId = s.DeptId,
                    DeptName = s.DeptName,
                    DeptDescription = s.DeptDescription,
                    DeptHead = s.DeptHead,
                    DeptHeadSalary = (decimal)s.DeptHeadSalary,
                    StateName = sa.StateName,
                    StateId = sa.StateId
                }).ToList();
                return(View());
            }
            #endregion

            #region #########SHOW###############
            if (!string.IsNullOrEmpty(Update))
            {
                if (ModelState.IsValid)
                {
                    db.Entry(obj).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["alert"] = "2";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    string messages = string.Join("; ", ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                }
            }
            #endregion

            return(RedirectToAction("Index")); // call pageload
        }