public int AddMinor(string nIdentifier, string nTitle, string nDescription, int nCreatedBy)
        {
            User creator = GetUser(nCreatedBy);
            string CreatorName = creator.userName;

            var newMinor = new Minor
            {
                Identifier = nIdentifier,
                Title = nTitle,
                Description = nDescription,

                CreatedBy = nCreatedBy,
                CreatedOn = DateTime.Now,
                CreatedByName = CreatorName
            };

            context.Minors.Add(newMinor);
            var result = context.SaveChanges();
            return result;
        }
        public ActionResult Edit(Minor minor)
        {
            if (ModelState.IsValid)
            {

                var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
                FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
                var username = ticket.Name;
                var user = repository.Users.SingleOrDefault(u => u.userName == username);
                int userid = user.id;

                minor.ModifiedBy = userid;
                minor.ModifiedOn = DateTime.Now;
                minor.ModifiedByName = username;

                var result = repository.EditMinor(minor);
                if (result > 0)
                    TempData["message"] = string.Format("Minor {0} has been saved.", minor.Identifier);
                else
                    TempData["message"] = string.Format("Unsuccessful procedure!");
            }
            return RedirectToAction("MinorList", "MinorManagement");
        }
 public int EditMinor(Minor minor)
 {
     context.Entry(minor).State = System.Data.EntityState.Modified;
     var result = context.SaveChanges();
     return result;
 }