コード例 #1
0
 public int EditSkillset(Skillset skillset)
 {
     context.Entry(skillset).State = System.Data.EntityState.Modified;
     var result = context.SaveChanges();
     return result;
 }
コード例 #2
0
        public int AddSkillset(string nIdentifier, string nTitle, string nDescription, int nCreatedBy)
        {
            User creator = GetUser(nCreatedBy);
            string CreatorName = creator.userName;

            var newSkillset = new Skillset
            {
                Identifier = nIdentifier,
                Title = nTitle,
                Description = nDescription,

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

            context.Skillsets.Add(newSkillset);
            var result = context.SaveChanges();
            return result;
        }
コード例 #3
0
        public ActionResult Edit(Skillset skillset)
        {
            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;

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

                var result = repository.EditSkillset(skillset);
                if (result > 0)
                    TempData["message"] = string.Format("Skillset {0} has been saved.", skillset.Identifier);
                else
                    TempData["message"] = string.Format("Unsuccessful procedure!");
            }
            return RedirectToAction("SkillsetList", "SkillsetManagement");
        }