Esempio n. 1
0
        public async Task <ActionResult> PutAsync(int id, [FromBody] Collaterals item)
        {
            if (!ModelState.IsValid || id != item.id)
            {
                return(BadRequest());
            }
            try
            {
                var exist = await service.GetByIdAsync(id);

                if (exist != null)
                {
                    var result = await service.UpdateAsync(item);

                    return(result ? Ok(item) : StatusCode(500, new Response()
                    {
                        Status = false, Description = "Error updating record"
                    }));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(StatusCode(500, new Response()
                {
                    Status = false, Description = "System error"
                }));
            }
        }
 public void SeedData()
 {
     Collaterals.Add(
         new Land()
     {
         Id                  = 3001,
         LoanId              = 1001,
         CustomerId          = 2001,
         InitialAssesDate    = DateTime.Now.AddDays(-5),
         LastAssessDate      = DateTime.Now,
         AreaInSqFt          = 1000,
         InitialPricePerSqFt = 1000,
         CurrentPricePerSqFt = 2000
     });
     Collaterals.Add(
         new RealEstate()
     {
         Id                     = 3002,
         LoanId                 = 1001,
         CustomerId             = 2001,
         InitialAssesDate       = DateTime.Now.AddDays(-6),
         LastAssessDate         = DateTime.Now,
         AreaInSqFt             = 1100,
         InitialLandPriceInSqFt = 1000,
         CurrentLandPriceInSqFt = 2000,
         InitialStructurePrice  = 100000,
         CurrentStructurePrice  = 200000,
         YearBuilt              = 2004
     });
     Collaterals.Add(
         new Land()
     {
         Id                  = 3003,
         LoanId              = 1002,
         CustomerId          = 2001,
         InitialAssesDate    = DateTime.Now.AddDays(-7),
         LastAssessDate      = DateTime.Now,
         AreaInSqFt          = 1200,
         InitialPricePerSqFt = 1000,
         CurrentPricePerSqFt = 2000
     });
     Collaterals.Add(
         new RealEstate()
     {
         Id                     = 3004,
         LoanId                 = 1003,
         CustomerId             = 2002,
         InitialAssesDate       = DateTime.Now.AddDays(-8),
         LastAssessDate         = DateTime.Now,
         AreaInSqFt             = 1300,
         InitialLandPriceInSqFt = 1000,
         CurrentLandPriceInSqFt = 2000,
         InitialStructurePrice  = 100000,
         CurrentStructurePrice  = 200000,
         YearBuilt              = 2004
     });
     SaveChanges();
 }
Esempio n. 3
0
        public async Task <ActionResult> PostAsync([FromBody] Collaterals item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            try
            {
                var exist = await service.GetAsync(x => x.customerid == item.customerid& x.description == item.description);

                if (exist != null)
                {
                    return(Conflict(new Response()
                    {
                        Status = false, Description = "Duplicate record"
                    }));
                }
                var result = await service.AddAsync(item);

                if (result)
                {
                    var newitem = await service.GetAsync(x => x.customerid == item.customerid& x.description == item.description);

                    return(StatusCode(201, newitem));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(StatusCode(500, new Response()
                {
                    Status = false, Description = "System error"
                }));
            }
        }
Esempio n. 4
0
 public IQueryable <DbCollateral> GetCollaterals() => Collaterals.AsQueryable();