Example #1
0
 public async Task <IActionResult> AddSite(AddSiteModel model)
 {
     try
     {
         await _driveAccount.AddSiteId(model.siteName, model.nickName);
     }
     catch (Exception ex)
     {
         return(StatusCode(500, new ErrorResponse()
         {
             message = ex.Message
         }));
     }
     return(StatusCode(201));
 }
        public async Task <IActionResult> AddSite([FromBody] AddSiteModel asm)
        {
            short id = 0;

            try
            {
                string Location = asm.Location.Trim().Replace(" ", "+");
                _context.Sites.Add(new Models.Sites()
                {
                    Name       = asm.Name,
                    Short_name = asm.Short_name,
                    Location   = asm.Location
                });
                await _context.SaveChangesAsync();

                id = (from s in _context.Sites orderby s.Site_id ascending select s.Site_id).Last();
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(BadRequest());
            }
            return(Ok(id));
        }