コード例 #1
0
        public ActionResult AddCountry(int?id, addcountry addcountry)
        {
            var  Emailid = User.Identity.Name.ToString();
            User user1   = dbobj.Users.Where(x => x.EmailId == Emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                Country noteCategory = dbobj.Countries.Find(id);
                if (noteCategory != null)
                {
                    noteCategory.name               = addcountry.name;
                    noteCategory.CountryCode        = addcountry.CountryCode;
                    noteCategory.ModifiedBy         = user1.ID;
                    noteCategory.Modifieddate       = DateTime.Now;
                    dbobj.Entry(noteCategory).State = EntityState.Modified;
                    dbobj.SaveChanges();
                }
                else
                {
                    Country note = new Country
                    {
                        name        = addcountry.name,
                        CountryCode = addcountry.CountryCode,
                        CreatedBy   = user1.ID,
                        Createddate = DateTime.Now,
                        isActive    = true,
                    };
                    dbobj.Countries.Add(note);
                    dbobj.SaveChanges();
                }
            }
            return(RedirectToAction("ManageCountry", "ManageSystem"));
        }
コード例 #2
0
        public ActionResult AddCountry(int?id)
        {
            Country noteCategory = dbobj.Countries.Find(id);

            if (noteCategory != null)
            {
                addcountry add = new addcountry
                {
                    name        = noteCategory.name,
                    CountryCode = noteCategory.CountryCode,
                };
                return(View(add));
            }
            else
            {
                return(View());
            }
            return(View());
        }