// POST: odata/TitleCategories public IHttpActionResult Post(TitleCategory titleCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TitleCategories.Add(titleCategory); db.SaveChanges(); return(Created(titleCategory)); }
public TitlesGump(PlayerMobile pm, TitleType type = TitleType.None, TitleCategory cat = TitleCategory.None, bool description = false) : base(50, 50) { User = pm; TitleType = type; Category = cat; AddPage(0); ButtonCallbacks = new Dictionary<GumpButton, Action<GumpButton>>(); AddGumpLayout(); }
public TitlesGump(PlayerMobile pm, TitleType type = TitleType.None, TitleCategory cat = TitleCategory.None, bool description = false) : base(50, 50) { User = pm; TitleType = type; Category = cat; AddPage(0); ButtonCallbacks = new Dictionary <GumpButton, Action <GumpButton> >(); AddGumpLayout(); }
// DELETE: odata/TitleCategories(5) public IHttpActionResult Delete([FromODataUri] int key) { TitleCategory titleCategory = db.TitleCategories.Find(key); if (titleCategory == null) { return(NotFound()); } db.TitleCategories.Remove(titleCategory); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
internal static IEnumerable <CustomField> GenerateCustomFields(TitleCategory category) { List <CustomField> customFields = new List <CustomField>(); switch (category) { case TitleCategory.Book: customFields.Add(new CustomField("Author", typeof(String))); customFields.Add(new CustomField("HardCover", typeof(bool))); customFields.Add(new CustomField("Amazon Rank", typeof(int))); break; case TitleCategory.Movie: customFields.Add(new CustomField("Director", typeof(String))); customFields.Add(new CustomField("Rating", typeof(MovieRating))); customFields.Add(new CustomField("Duration", typeof(TimeSpan))); customFields.Add(new CustomField("Release Date", typeof(DateTime))); break; } return(customFields); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <TitleCategory> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TitleCategory titleCategory = db.TitleCategories.Find(key); if (titleCategory == null) { return(NotFound()); } patch.Patch(titleCategory); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TitleCategoryExists(key)) { return(NotFound()); } else { throw; } } return(Updated(titleCategory)); }
public Title(string name, TitleCategory category) { Name = name; Category = category; }
public Title(String name, TitleCategory category) { this.Name = name; this.Category = category; }
public async Task<bool> IsByNameExist(string name, Guid? id, TitleType type, TitleCategory category) { var titles = await _titles.Select(a => new { Id = a.Id, Name = a.Name, Type = a.Type, Category = a.Category }).ToListAsync(); return id == null ? titles.Any( a => a.Name.GetFriendlyPersianName() == name.GetFriendlyPersianName() && a.Type == type && a.Category == category) : titles.Any( a => a.Id != id & a.Name.GetFriendlyPersianName() == name.GetFriendlyPersianName() && a.Type == type && a.Category == category); }