/// <summary> /// Level: Logic /// </summary> /// <param name="UserTypeID">The UserTypeID</param> /// <returns>UserTypeDelete Enum</returns> public UserTypeDelete DeleteUserType(int UserTypeID) { try { UserTypesRepository myRepository = new UserTypesRepository(); if (myRepository.UserTypeIsRetailerOrWholesaler(UserTypeID)) { return(UserTypeDelete.LockedUserType); } else if (myRepository.UserTypeHasUsers(UserTypeID)) { return(UserTypeDelete.HasUsers); } else { myRepository.DeleteUserType(UserTypeID); return(UserTypeDelete.Successful); } } catch (Exception Exception) { throw Exception; } }
/// <summary> /// Adds a New UserType /// Level: Logic /// </summary> /// <param name="UserType">The UserType</param> /// <returns>True if Successful, False if Not</returns> public bool AddUserType(string UserType) { try { UserTypesRepository myRepository = new UserTypesRepository(); if (!myRepository.UserTypeExists(UserType)) { Common.UserType myUserType = new UserType(); myUserType.Type = UserType; myRepository.AddUserType(myUserType); return(true); } else { return(false); } } catch (Exception Exception) { throw Exception; } }
/// <summary> /// Updates a UserType /// Level: Logic /// </summary> /// <param name="UserTypeID">The UserTypeID</param> /// <param name="UserType">The UserType</param> /// <returns>UserTypeUpdate Enum</returns> public UserTypeUpdate UpdateUserType(int UserTypeID, string UserType) { try { UserTypesRepository myRepository = new UserTypesRepository(); if (myRepository.UserTypeIsRetailerOrWholesaler(UserTypeID)) { return(UserTypeUpdate.LockedUserType); } else if (myRepository.UserTypeExists(UserType)) { return(UserTypeUpdate.SameUserType); } else { myRepository.UpdateUserType(UserTypeID, UserType); return(UserTypeUpdate.Successful); } } catch (Exception Exception) { throw Exception; } }
public SelectList GetUserTypesAndSelect(string currentType) { using (var userTypesRepository = new UserTypesRepository(new MyTubeDBEntities())) { var userType = userTypesRepository.GetUserTypes(); return(new SelectList(userType, "TypeName", "TypeName", currentType)); } }
public IHttpActionResult UpdateUserTypeStatus([FromBody] UserTypes usertype) { var usertypeRepo = new UserTypesRepository(); var result = usertypeRepo.UpdateUserTypeStatus(usertype); if (result <= 0) { return(Ok("Error occurred while updating the user type status")); } return(Ok("User Type Status updated")); }
public IHttpActionResult GetUserType([FromBody] UserTypes usertype) { var usertypeRepo = new UserTypesRepository(); var getusertype = usertypeRepo.GetUserType(usertype); if (getusertype == null) { return(NotFound()); } return(Ok(getusertype)); }
// GET: api/UserType public IHttpActionResult GetAllUserTypes() { var usertypeRepo = new UserTypesRepository(); var usertypesList = usertypeRepo.GetAllUserTypes(); if (usertypesList == null || usertypesList.Count == 0) { return(NotFound()); } return(Ok(usertypesList)); }