예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
        // 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());
        }
예제 #4
0
        public IHttpActionResult Post(SpendTypeRequest SpendType)
        {
            var result = SpendTypeService.CreateSpendType(SpendType);

            return(Created <Entidad>("", new Entidad {
                Id = result.Id
            }));
        }
예제 #5
0
 public bool UpdateSpendType(SpendTypeRequest SpendType)
 {
     return(IntegrationService.RestCallNoReturn(ConfigurationManager.AppSettings["ApiCoreUrl"], string.Format(ApiCore.UpdateSpendType, SpendType.Id), RestMethod.Put, null, SpendType));
 }
예제 #6
0
 public Entidad CreateSpendType(SpendTypeRequest SpendType)
 {
     return(IntegrationService.RestCall <Entidad>(ConfigurationManager.AppSettings["ApiCoreUrl"], ApiCore.CreateSpendType, RestMethod.Post, null, SpendType));
 }
예제 #7
0
 public SpendType UpdateSpendType(SpendType originalSpend, SpendTypeRequest Spend)
 {
     this.MergeSpendType(originalSpend, Spend);
     SpendTypeRepository.Update(originalSpend);
     return(originalSpend);
 }