public async Task <ReportCodeDto> CreateNew(OfficeLocationDto officeLocationDto)
        {
            var code = await _qualityReportManager.CreateNew(_appMapper.Map <OfficeLocation>(officeLocationDto));

            var mapped = _appMapper.Map <ReportCodeDto>(code);

            return(mapped);
        }
        public int AddLocation(OfficeLocationDto location)
        {
            try
            {
                int insertedId = 0;
                if (!_context.OfficeLocation.Any(r => r.Address == location.Address && r.IsDeleted == false))
                {
                    var office_location = new OfficeLocation
                    {
                        Address = location.Address
                    };
                    _context.OfficeLocation.Add(office_location);
                    _context.SaveChanges();
                    insertedId = office_location.Id;
                }
                return(insertedId);
            }

            catch
            {
                return(0);
            }
        }
Beispiel #3
0
 public IActionResult Post([FromBody] OfficeLocationDto officelocation)
 {
     try
     {
         if (officelocation == null)
         {
             return(BadRequest());
         }
         var response = locationService.AddLocation(officelocation);
         if (response == 0)
         {
             return(BadRequest());
         }
         else
         {
             return(Ok(officelocation));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }