示例#1
0
        // POST: odata/TitleCategories
        public IHttpActionResult Post(TitleCategory titleCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TitleCategories.Add(titleCategory);
            db.SaveChanges();

            return(Created(titleCategory));
        }
示例#2
0
        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();
        }
示例#3
0
        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();
        }
示例#4
0
        // 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));
        }
示例#5
0
        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);
        }
示例#6
0
        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));
        }
示例#7
0
 public Title(string name, TitleCategory category)
 {
     Name     = name;
     Category = category;
 }
示例#8
0
 public Title(String name, TitleCategory category)
 {
     this.Name     = name;
     this.Category = category;
 }
示例#9
0
        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);

        }