Пример #1
0
        public WebmasterInfo ConvertToEF(WebmasterInfoDTO DTO)
        {
            var EF = new WebmasterInfo()
            {
                WebmasterInfoId = DTO.WebmasterInfoId,
                WIFullName      = DTO.WIFullName,
                WIStatus        = DTO.WIStatus,
                WIType          = DTO.WIType,
                WIUserName      = DTO.WIUserName,
                WI_AspNetUserId = DTO.WI_AspNetUserId,
                WIBirthDay      = DTO.WIBirthDay,
                WIGender        = DTO.WIGender,
                WIAddress       = DTO.WIAddress,
                WIDateStart     = DTO.WIDateStart,
                WIPosition      = DTO.WIPosition
            };

            if (DTO.AspNetUserDTO != null)
            {
                EF.AspNetUser = _aspnetuserConvert.ConvertToEF(DTO.AspNetUserDTO);
            }


            return(EF);
        }
Пример #2
0
        public WebmasterInfoDTO ConvertToDTO(WebmasterInfo EF)
        {
            var DTO = new WebmasterInfoDTO()
            {
                WebmasterInfoId = EF.WebmasterInfoId,
                WIFullName      = EF.WIFullName,
                WIStatus        = EF.WIStatus,
                WIType          = EF.WIType,
                WIUserName      = EF.WIUserName,
                WI_AspNetUserId = EF.WI_AspNetUserId,
                WIBirthDay      = EF.WIBirthDay,
                WIGender        = EF.WIGender,
                WIAddress       = EF.WIAddress,
                WIDateStart     = EF.WIDateStart,
                WIPosition      = EF.WIPosition
            };

            if (EF.WIBirthDay != null)
            {
                DTO.WIBirthdayString = EF.WIBirthDay.Value.ToString("yyyy-MM-dd");
            }
            if (EF.AspNetUser != null)
            {
                DTO.AspNetUserDTO = _aspnetuserConvert.ConvertToDTO(EF.AspNetUser);
                DTO.WIEmail       = DTO.AspNetUserDTO.Email;
                DTO.WIPhoneNumber = DTO.AspNetUserDTO.PhoneNumber;
            }

            switch (EF.WIPosition)
            {
            case (int)BU.Common.Enum.WIPosition.Admin:
                DTO.nameRole = "Quản trị";
                break;

            default:
                DTO.nameRole = "Nhân viên";
                break;
            }


            switch (EF.WIStatus)
            {
            case (int)BU.Common.Enum.StatusAccount.Active:
                DTO.WIStatusString = "Active";
                break;

            case (int)BU.Common.Enum.StatusAccount.Approvaling:
                DTO.WIStatusString = "Waiting for approval";
                break;

            case (int)BU.Common.Enum.StatusAccount.Block:
                DTO.WIStatusString = "Pause";
                break;

            default:
                DTO.WIStatusString = "Deleted";
                break;
            }
            return(DTO);
        }
Пример #3
0
        public int Update(WebmasterInfo ef)
        {
            try
            {
                var get = db.WebmasterInfoes.Find(ef.WebmasterInfoId);

                get.WIUserName = ef.WIUserName;
                get.WIFullName = ef.WIFullName;
                get.WIAddress  = ef.WIAddress;
                get.WIGender   = ef.WIGender;
                get.WIBirthDay = ef.WIBirthDay;
                get.WIStatus   = ef.WIStatus;
                get.WIPosition = ef.WIPosition;
                get.WIType     = ef.WIType;

                db.SaveChanges();
                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }