Ejemplo n.º 1
0
        private MD.Common.Common_Authen_User ConvertToDataModel(VM.VmTblUser model, MD.Common.Common_Authen_User dbModel)
        {
            if (model == null)
            {
                return(null);
            }
            if (dbModel == null)
            {
                //when update, will pass a dbModel into
                //MD.Common.Common_Authen_User
                dbModel = new MD.Common.Common_Authen_User();
            }

            dbModel.UserID       = model.UserID;
            dbModel.LogonName    = model.LogonName;
            dbModel.Password     = model.Password;
            dbModel.UserName     = model.UserName;
            dbModel.Gender       = model.Gender;
            dbModel.PhoneNumber  = model.PhoneNumber;
            dbModel.EmailAddress = model.EmailAddress;
            dbModel.IDNumber     = model.IDNumber;
            dbModel.DateOFBirth  = model.DateOFBirth;
            dbModel.Status       = model.Status;
            dbModel.CanDelete    = model.CanDelete;

            dbModel.CreatedBy   = model.CreatedBy;
            dbModel.UpdatedDate = model.UpdatedDate;
            dbModel.CreatedDate = model.CreatedDate;
            dbModel.UpdatedBy   = model.UpdatedBy;

            return(dbModel);
        }
Ejemplo n.º 2
0
        private VM.VmTblUser ConvertToViewModel(MD.Common.Common_Authen_User mdUser)
        {
            if (mdUser == null)
            {
                return(null);
            }
            VM.VmTblUser vmModel = new VM.VmTblUser();
            vmModel.UserID       = mdUser.UserID;
            vmModel.LogonName    = mdUser.LogonName;
            vmModel.Password     = mdUser.Password;
            vmModel.UserName     = mdUser.UserName;
            vmModel.Gender       = mdUser.Gender;
            vmModel.PhoneNumber  = mdUser.PhoneNumber;
            vmModel.EmailAddress = mdUser.EmailAddress;
            vmModel.IDNumber     = mdUser.IDNumber;
            vmModel.DateOFBirth  = mdUser.DateOFBirth;
            vmModel.Status       = mdUser.Status;
            vmModel.CanDelete    = mdUser.CanDelete;

            vmModel.CreatedBy   = mdUser.CreatedBy;
            vmModel.UpdatedDate = mdUser.UpdatedDate;
            vmModel.CreatedDate = mdUser.CreatedDate;
            vmModel.UpdatedBy   = mdUser.UpdatedBy;
            return(vmModel);
        }
Ejemplo n.º 3
0
        public bool CreateUser(VM.VmTblUser model)
        {
            if (model == null)
            {
                //Message = MessageModel.InsertFailue(MessageResource.FaultCode_Empty_ErrorMessage + "," + MessageResource.Message_CommonInsertFail);
                Message = MessageModel.InsertFailue("页面对象为空!");
                return(false);
            }
            var mdUser = this.ConvertToDataModel(model, null);

            context.Common_Authen_User.Add(mdUser);
            context.SaveChanges();
            Message = MessageModel.InsertSuccess();
            return(true);
        }
Ejemplo n.º 4
0
        public bool UpdateUser(VM.VmTblUser model)
        {
            if (model == null)
            {
                Message = MessageModel.UpdateFailue("对象为空!");
                return(false);
            }
            if (!context.Common_Authen_User.Any(i => i.UserID == model.UserID))
            {
                Message = MessageModel.UpdateFailue("目标对象不存在!");
                return(false);
            }
            MD.Common.Common_Authen_User mdUser = context.Common_Authen_User.First(i => i.UserID == model.UserID);
            mdUser = this.ConvertToDataModel(model, mdUser);
            //context.Entry(mdUser).State = EntityState.Modified; //?
            context.SaveChanges();

            Message = MessageModel.UpdateSuccess();
            return(true);
        }
Ejemplo n.º 5
0
 public bool IsExistUser(VM.VmTblUser model)
 {
     return(context.Common_Authen_User.Any(i => i.LogonName == model.LogonName));
 }