示例#1
0
 public bool AddSkill(Skill skill)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             context.Skills.Add(new EntityFramework.Skill
             {
                 Name    = skill.Name,
                 AddedBy = skill.AddedBy,
                 AddedOn = DateTime.Now
             });
             return(context.SaveChanges() > 0);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         return(false);
     }
 }
示例#2
0
 /// <summary>
 /// Method to Add new skill to fetch Id
 /// </summary>
 /// <param name="skill">Instances data for new skill to be added</param>
 /// <exception >On exceptions rethrows the exception,need to handle in calling function</exception>
 /// <returns>Skill Id</returns>
 public int AddNewSkillForId(Skill skill)
 {
     try
     {
         using (var context = new TrainingTrackerEntities())
         {
             EntityFramework.Skill newSkill = new EntityFramework.Skill
             {
                 Name    = skill.Name,
                 AddedBy = skill.AddedBy,
                 AddedOn = DateTime.Now
             };
             context.Skills.Add(newSkill);
             context.SaveChanges();
             return(newSkill.SkillId);
         }
     }
     catch (Exception ex)
     {
         LogUtility.ErrorRoutine(ex);
         throw ex;
     }
 }