private void MergeSpendType(SpendType originalSpendType, SpendTypeRequest SpendType) { originalSpendType.Consortium = this.ConsortiumRepository.GetById(SpendType.ConsortiumId); originalSpendType.Description = SpendType.Description; originalSpendType.Required = SpendType.Required; originalSpendType.Item = this.SpendItemRepository.GetById(SpendType.SpendItemId); }
public SpendType CreateSpendType(SpendTypeRequest SpendType) { var entity = new SpendType(); this.MergeSpendType(entity, SpendType); this.SpendTypeRepository.Insert(entity); if (SpendType.ForAll) { var consortiums = this.ConsortiumRepository.GetAll().Where(x => x.Id != SpendType.ConsortiumId) .Select(x => x.Id) .ToList(); consortiums.ForEach(x => { var nentity = new SpendType(); this.MergeSpendType(nentity, SpendType); nentity.Consortium = this.ConsortiumRepository.GetById(x); this.SpendTypeRepository.Insert(nentity); }); } return(entity); }
// PUT api/<controller>/5 /// <summary> /// Modifica un SpendType /// </summary> /// <param name="SpendType">SpendType a modificar</param> /// <returns></returns> public IHttpActionResult Put(int id, SpendTypeRequest SpendType) { var originalSpendType = SpendTypeService.GetById(id); var ret = SpendTypeService.UpdateSpendType(originalSpendType, SpendType); return(Ok()); }
public IHttpActionResult Post(SpendTypeRequest SpendType) { var result = SpendTypeService.CreateSpendType(SpendType); return(Created <Entidad>("", new Entidad { Id = result.Id })); }
public bool UpdateSpendType(SpendTypeRequest SpendType) { return(IntegrationService.RestCallNoReturn(ConfigurationManager.AppSettings["ApiCoreUrl"], string.Format(ApiCore.UpdateSpendType, SpendType.Id), RestMethod.Put, null, SpendType)); }
public Entidad CreateSpendType(SpendTypeRequest SpendType) { return(IntegrationService.RestCall <Entidad>(ConfigurationManager.AppSettings["ApiCoreUrl"], ApiCore.CreateSpendType, RestMethod.Post, null, SpendType)); }
public SpendType UpdateSpendType(SpendType originalSpend, SpendTypeRequest Spend) { this.MergeSpendType(originalSpend, Spend); SpendTypeRepository.Update(originalSpend); return(originalSpend); }