public override Model.Instructor Insert(InstructorInsertRequest model) { var entity = _mapper.Map <Database.User>(model); _context.Add(entity); entity.PasswordSalt = GenerateSalt(); entity.PasswordHash = GenerateHash(entity.PasswordSalt, model.Password); _context.SaveChanges(); return(_mapper.Map <Model.Instructor>(entity)); }
public override Model.Instructor Update(int id, InstructorInsertRequest model) { var entity = _context.Users.Find(id); if (!string.IsNullOrEmpty(model.Password)) { entity.PasswordHash = GenerateHash(entity.PasswordSalt, model.Password); } _mapper.Map(model, entity); _context.Attach(entity); _context.Update(entity); _context.SaveChanges(); return(_mapper.Map <Model.Instructor>(entity)); }