public bool PutUserType(user_type user_type) { try { if (ValidatorUserType.IsUSerTypeExist(user_type, GetAllUserType())) { db.Entry(user_type).State = EntityState.Modified; db.SaveChanges(); return(true); } else if (!ValidatorUserType.IsUSerTypeExist(user_type, GetAllUserType())) { throw new ItemNotExistException("user_type"); } else { throw new InvalidItemException("user_type"); } } catch (Exception e) { throw e; } }
public bool PostUserType(user_type type) { try { if (type.type.Length > 0 && type.type.Length < 11) { db.user_type.Add(type); db.SaveChanges(); return(true); } else if (ValidatorUserType.IsUSerTypeExist(type, GetAllUserType())) { throw new ExistingItemException("user_type"); } else { throw new InvalidItemException("user_type"); } } catch (Exception e) { throw e; } }