예제 #1
0
        public ResultHelper AddUserContactType(UserContactTypeDto userContactTypeDto)
        {
            try
            {
                if (IsThere(userContactTypeDto))
                {
                    return(new ResultHelper(false, 0, ResultHelper.SuccessMessage));
                }
                usercontacttype item = new usercontacttype();
                item.UserContactTypeID = userContactTypeDto.UserContactTypeID;
                item.TypeName          = userContactTypeDto.TypeName;
                item.Description       = userContactTypeDto.Description;

                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    unitOfWork.GetRepository <usercontacttype>().Insert(item);
                    unitOfWork.saveChanges();
                    return(new ResultHelper(true, item.UserContactTypeID, ResultHelper.SuccessMessage));
                }
            }
            catch (Exception ex)
            {
                return(new ResultHelper(false, 0, ResultHelper.UnSuccessMessage));
            }
        }
예제 #2
0
        public UserContactTypeDto GetUserContactType(int userContactTypeID)
        {
            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    usercontacttype item = new usercontacttype();
                    item = unitOfWork.GetRepository <usercontacttype>().GetById(x => x.UserContactTypeID == userContactTypeID);
                    UserContactTypeDto userContactTypeDto = new UserContactTypeDto();
                    userContactTypeDto.TypeName          = item.TypeName;
                    userContactTypeDto.UserContactTypeID = item.UserContactTypeID;
                    userContactTypeDto.Description       = item.Description;

                    return(userContactTypeDto);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }