public IHttpActionResult GetById(int id) { AncestryModel ancestryModel = _service.GetById <AncestryModel>(id); if (ancestryModel != null) { return(Json(ancestryModel)); } else { return(BadRequest()); } }
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); } }
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); } }
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); } }
public IHttpActionResult Post([FromBody] AncestryModel ancestryModel) { if (ancestryModel.Identifier != null) { if (_service.Post <AncestryModel>(ancestryModel)) { return(Ok()); } else { return(BadRequest()); } } else { return(BadRequest()); } }
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()); } }
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); } }