예제 #1
0
 public Dalyan.Entities.Models.User Handler(UserEditQuery query)
 {
     try
     {
         var obj = new Dalyan.Db.User();
         obj                  = _db.User.FirstOrDefault(x => x.Id == query.User.Id);
         obj.Id               = query.User.Id;
         obj.CompanyId        = query.User.CompanyId;
         obj.Name             = query.User.Name;
         obj.Email            = query.User.Email;
         obj.UserType         = query.User.UserType;
         obj.CreatedDate      = query.User.CreatedDate;
         obj.CreatedIpAddress = query.User.CreatedIpAddress;
         obj.CreatedUserId    = query.User.CreatedUserId;
         obj.UpdatedDate      = query.User.UpdatedDate;
         obj.UpdatedIpAddress = query.User.UpdatedIpAddress;
         obj.UpdatedUserId    = query.User.UpdatedUserId;
         obj.IsDeleted        = query.User.IsDeleted;
         _db.SaveChanges();
         return(query.User);
     }
     catch (Exception ex)
     {
         throw new ExceptionLog(LogType.DATABASE_UPDATE, LogLevel.ERROR, ex, "EditQueryHandler");
     }
 }
예제 #2
0
 public Dalyan.Entities.Models.User Handler(UserAddQuery query)
 {
     try
     {
         string password = StringHelper.GeneratePassword(8);
         var    obj      = new Dalyan.Db.User();
         obj.Id               = query.User.Id;
         obj.CompanyId        = query.User.CompanyId;
         obj.Password         = password;
         obj.Name             = query.User.Name;
         obj.Email            = query.User.Email;
         obj.UserType         = query.User.UserType;
         obj.CreatedDate      = query.User.CreatedDate;
         obj.CreatedIpAddress = query.User.CreatedIpAddress;
         obj.CreatedUserId    = query.User.CreatedUserId;
         obj.UpdatedDate      = query.User.UpdatedDate;
         obj.UpdatedIpAddress = query.User.UpdatedIpAddress;
         obj.UpdatedUserId    = query.User.UpdatedUserId;
         obj.IsDeleted        = query.User.IsDeleted;
         _db.User.Add(obj);
         _db.SaveChanges();
         query.User.Id = obj.Id;
         return(query.User);
     }
     catch (Exception ex)
     {
         throw new ExceptionLog(LogType.DATABASE_INSERT, LogLevel.ERROR, ex, "AddQueryHandler");
     }
 }
예제 #3
0
        public bool Handler(Dalyan.Domain.Query.UserDeleteQuery query)
        {
            try
            {
                var obj = new Dalyan.Db.User();
                obj = _db.User.FirstOrDefault(x => x.Id == query.Id);

                obj.IsDeleted = true;
                _db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw new ExceptionLog(LogType.DATABASE_DELETE, LogLevel.ERROR, ex, "DeleteQueryHandler");
            }
        }
 public bool Handler(ChangePasswordQuery query)
 {
     try
     {
         var obj = new Dalyan.Db.User();
         obj             = _db.User.FirstOrDefault(x => x.Id == query.Id);
         obj.Password    = query.Password;
         obj.UpdatedDate = DateTime.Now;
         _db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         throw new ExceptionLog(LogType.DATABASE_UPDATE, LogLevel.ERROR, ex, "ChangePasswordQuery");
     }
 }