public static string ProfessionName(UserProfession profession) { string name = string.Empty; professionName.TryGetValue(profession, out name); return(name); }
internal object AddProfession(int userId, int professionId) { try { UserProfession userProfession = _dbContext.UserProfessions.Where(u => u.UserId == userId && u.ProfessionId == professionId).FirstOrDefault(); if (userProfession == null) { User user = _dbContext.Users.Find(userId); if (user.UserType == "Customer") { user.UserType = "Vendor"; _dbContext.Entry(user).State = EntityState.Modified; _dbContext.SaveChanges(); } UserProfession new_profession = new UserProfession { UserId = userId, ProfessionId = professionId }; _dbContext.UserProfessions.Add(new_profession); _dbContext.SaveChanges(); return("true"); } else { return("false"); } } catch (Exception ex) { return("{success:" + ex.Message + "}"); } }
public static string TitleBackground(UserProfession title) { if (AllTitleBackground.TryGetValue(title, out string v)) { return(v); } return(string.Empty); }
internal object DeleteProfession(int id) { UserProfession userProfession = _roofCareDbContext.UserProfessions.Find(id); if (userProfession != null) { _roofCareDbContext.UserProfessions.Remove(userProfession); _roofCareDbContext.SaveChanges(); return("Success"); } else { return("Already Deleted"); } }
public bool HasTitle(UserProfession profession) { if (profession == UserProfession.None) { return(true); } if (Titles == null) { return(false); } BitArray ba = new BitArray(Titles); if (ba.Length < (int)profession) { return(false); } return(ba.Get((int)profession - 1)); }
public void AddTitle(UserProfession profession) { if (Titles == null) { Titles = new byte[1]; } var bitPos = (int)profession - 1; int len = Math.Max(Titles.Length, (bitPos + 8) / 8); BitArray ba = new BitArray(Titles) { Length = len * 8 }; ba.Set(bitPos, true); var newTitles = new byte[len]; ba.CopyTo(newTitles, 0); Titles = newTitles; }