コード例 #1
0
        public UsersDTO FindById(int id)
        {
            UsersDTO model = new UsersDTO();
            userModel = userService.Find(id);

            Mapper.CreateMap<Users, UsersDTO>();
            model = Mapper.Map<UsersDTO>(userModel);
            return model;
        }
コード例 #2
0
        public UsersDTO FindByEmail(string email)
        {
            UsersDTO model = new UsersDTO();
            userModel = userService.FindByEmail(email);

            Mapper.CreateMap<Users, UsersDTO>();
            model = Mapper.Map<UsersDTO>(userModel);
            return model;
        }
コード例 #3
0
 public string CreateEntity(Users model)
 {
     string transactionMessage = "";
     try
     {
             db.Users.Add(model);
             db.SaveChanges();
             transactionMessage = "Succes!";
     }
     catch (Exception ex)
     {
         transactionMessage = "Error " + ex.Message;
     }
     return transactionMessage;
 }
コード例 #4
0
 public void Transform_Users_UsersDTO(UsersDTO model)
 {
     Mapper.CreateMap<UsersDTO, Users>();
     userModel = Mapper.Map<Users>(model);
 }
コード例 #5
0
        public string UpdateEntity(Users model)
        {
            String transactionMessage = null;
            try
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                transactionMessage = "User updated!";
            }
            catch(Exception ex) {

                transactionMessage = "Error: " + ex.Message;
            }
            return transactionMessage;
        }