コード例 #1
0
        public IHttpActionResult GetById(int id)
        {
            AncestryModel ancestryModel = _service.GetById <AncestryModel>(id);

            if (ancestryModel != null)
            {
                return(Json(ancestryModel));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        public bool Post(AncestryModel ancestryModel)
        {
            AncestryRepository ancestryRepository = new AncestryRepository();

            try
            {
                Ancestry ancestry = new Ancestry();
                ancestry.Identifier = ancestryModel.Identifier;
                ancestryRepository.Insert(ancestry);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #3
0
        public bool Update(AncestryModel ancestryModel)
        {
            AncestryRepository ancestryRepository = new AncestryRepository();
            Ancestry           ancestry           = new Ancestry();

            try
            {
                ancestry.Id         = ancestryModel.Id;
                ancestry.Identifier = ancestryModel.Identifier;
                ancestryRepository.Update(ancestry);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #4
0
        public AncestryModel GetById(int id)
        {
            AncestryRepository ancestryRepository = new AncestryRepository();

            try
            {
                Ancestry      ancestry      = ancestryRepository.GetById(id);
                AncestryModel ancestryModel = new AncestryModel();
                ancestryModel.Id         = ancestry.Id;
                ancestryModel.Identifier = ancestry.Identifier;

                return(ancestryModel);
            }
            catch
            {
                return(null);
            }
        }
コード例 #5
0
 public IHttpActionResult Post([FromBody] AncestryModel ancestryModel)
 {
     if (ancestryModel.Identifier != null)
     {
         if (_service.Post <AncestryModel>(ancestryModel))
         {
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     else
     {
         return(BadRequest());
     }
 }
コード例 #6
0
 public IHttpActionResult Update([FromBody] AncestryModel ancestryModel)
 {
     if (ancestryModel != null || ancestryModel.Identifier != null)
     {
         bool result = _service.Update <AncestryModel>(ancestryModel);
         if (result == true)
         {
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     else
     {
         return(BadRequest());
     }
 }
コード例 #7
0
        public List <AncestryModel> Get()
        {
            GenericRepository <Ancestry> ancestryRepository = new GenericRepository <Ancestry>();

            try
            {
                List <Ancestry>      ancestrys      = ancestryRepository.Get();
                List <AncestryModel> ancestryModels = new List <AncestryModel>();
                foreach (Ancestry ancestry in ancestrys)
                {
                    AncestryModel ancestryModel = new AncestryModel();
                    ancestryModel.Id         = ancestry.Id;
                    ancestryModel.Identifier = ancestry.Identifier;

                    ancestryModels.Add(ancestryModel);
                }
                return(ancestryModels);
            }
            catch
            {
                return(null);
            }
        }