コード例 #1
0
        public ActionResult <IEnumerable <ProvisionDTO> > Provision([FromBody] ProvisionDTO provisionDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (provisionDTO == null)
            {
                return(BadRequest());
            }

            var checkProvisiondinDb = _choiceRepoistory.GetProvisions().Find(c => c.ProvisionId == provisionDTO.ProvisionId);

            if (checkProvisiondinDb != null)
            {
                return(BadRequest());
            }

            Provision newlyProvision = new Provision()
            {
                ProvisionId    = provisionDTO.ProvisionId,
                CRMPartnerId   = provisionDTO.CRMPartnerId,
                CustomerId     = provisionDTO.CustomerId,
                BookingId      = provisionDTO.BookingId,
                Price          = provisionDTO.Price,
                CreatedDate    = System.DateTime.Now,
                DateofShipment = provisionDTO.DateofShipment,
                Debtor         = provisionDTO.Debtor,
                ProvisionName  = provisionDTO.ProvisionName,
                UnitID         = provisionDTO.UnitID,
                CreatedBy      = provisionDTO.CreatedBy,
                ProvisionSpID  = provisionDTO.ProvisionSpID,
                LastModified   = provisionDTO.LastModified,
                LastModifiedBy = provisionDTO.LastModifiedBy,
            };

            _choiceRepoistory.SetProvision(newlyProvision);
            _choiceRepoistory.Complete();

            return(CreatedAtRoute("GetProvisions", new { name = newlyProvision.ProvisionName }, newlyProvision));
        }
コード例 #2
0
        public IActionResult UpdateProvision(int provisionId, [FromBody] ProvisionDTO provisionDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (provisionDTO == null)
            {
                return(BadRequest());
            }

            var provision = _choiceRepoistory.GetProvisions().Find(c => c.ProvisionId == provisionId);

            if (provision == null)
            {
                return(BadRequest());
            }

            provision = provisionDTO;

            _choiceRepoistory.Complete();
            return(NoContent());
        }