public IActionResult GetSingleBusiness(int id) { try { BusinessModel business = logic.GetSingleBusiness(id); if (business == null) { return(NotFound($"id {id} not found")); } return(Ok(business)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public IActionResult UpdateFullBusiness(int id, BusinessModel businessModel) { try { businessModel.BusinessId = id; BusinessModel updatedBusiness = logic.UpdateFullBusiness(businessModel); if (updatedBusiness == null) { return(NotFound($"id {id} not found")); } return(Ok(updatedBusiness)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public BusinessModel UpdateFullBusiness(BusinessModel businessModel) { Business business = DB.Businesses.SingleOrDefault(p => p.BusinessId == businessModel.BusinessId); if (business == null) { return(null); } business.BusinessName = businessModel.BusinessName; business.BusinessType = businessModel.BusinessType; business.BusinessPhone = businessModel.BusinessPhone; business.BusinessEmail = businessModel.BusinessEmail; business.CustomerName = businessModel.CustomerName; business.Role = business.Role; business.Username = DB.Businesses.SingleOrDefault(p => p.BusinessId == businessModel.BusinessId).Username; business.Password = DB.Businesses.SingleOrDefault(p => p.BusinessId == businessModel.BusinessId).Password; DB.SaveChanges(); return(businessModel); }