예제 #1
0
        public Operation DeleteSecUser(SecUser objSecUser)
        {
            Operation objOperation = new Operation { Success = true, OperationId = objSecUser.Id };
            _secUserRepository.Delete(objSecUser);

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception)
            {

                objOperation.Success = false;
            }
            return objOperation;
        }
예제 #2
0
        protected void Fill(DataRow dtrRow, SecUser user)
        {
            try
            {
                if (((!object.ReferenceEquals(dtrRow["Id"], DBNull.Value))))
                {
                    user.Id = (Int32)dtrRow["Id"];
                }
                else user.Id = 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            try
            {
                if (((!object.ReferenceEquals(dtrRow["HrmEmployeeId"], DBNull.Value))))
                {
                    user.HrmEmployeeId = (int)dtrRow["HrmEmployeeId"];
                }
                else user.HrmEmployeeId = 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            try
            {
                if (((!object.ReferenceEquals(dtrRow["LoginName"], DBNull.Value))))
                {
                    user.LoginName = (string)dtrRow["LoginName"];
                }
                else user.LoginName = string.Empty;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            try
            {
                if (((!object.ReferenceEquals(dtrRow["Password"], DBNull.Value))))
                {
                    user.Password = (string)dtrRow["Password"];
                }
                else user.Password = string.Empty;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            try
            {
                if (((!object.ReferenceEquals(dtrRow["Status"], DBNull.Value))))
                {
                    user.Status = (bool)dtrRow["Status"];
                }
                else user.Status = false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            try
            {
                if (((!object.ReferenceEquals(dtrRow["SecRoleId"], DBNull.Value))))
                {
                    user.SecRoleId = (int)dtrRow["SecRoleId"];
                }
                else user.SecRoleId = 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
 public SecUser GetUserByLogin(string loginName)
 {
     try
     {
         SecUser user = null;
         SqlParameter[] parameters = new SqlParameter[1];
         parameters[0] = new SqlParameter("@LoginName", loginName);
         DataTable dt = _secUserRepository.GetFromStoredProcedure(SPList.SecUser.GetSecUsersByLoginName, parameters);
         user = new SecUser();
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 Fill(row, user);
             }
         }
         return user;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        public Operation SaveSecUser(SecUser objSecUser)
        {
            Operation objOperation = new Operation { Success = true };

            long Id = _secUserRepository.AddEntity(objSecUser);
            objOperation.OperationId = Id;

            try
            {
                _UnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
            }
            return objOperation;
        }
예제 #5
0
 public ActionResult SaveUser(SecUser secUser)
 {
     int userId = Convert.ToInt32(Session["userId"]);
     Operation objOperation = new Operation { Success = false };
     if (ModelState.IsValid)
     {
         if (secUser.Id == 0)
         {
             secUser.CreatedBy = userId;
             secUser.CreatedDate = DateTime.Now.Date;
             objOperation = _su.SaveSecUser(secUser);
         }
         else
         {
             secUser.ModifiedBy = userId;
             secUser.ModifiedDate = DateTime.Now.Date;
             objOperation = _su.UpdateSecUser(secUser);
         }
     }
     return Json(objOperation, JsonRequestBehavior.DenyGet);
 }