Esempio n. 1
0
 public HttpResponseMessage EditBusiness([FromBody] bussinessDTO bussiness, string clientId)
 {
     try
     {
         bool is_edit = BusinessService.EditBusiness(bussiness);
         if (!is_edit)
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound, "There is no business id as this in db"));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, "The business was edit"));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e));
     }
 }
Esempio n. 2
0
 public HttpResponseMessage ChangeActiveBusiness([FromBody] bussinessDTO bussiness, string userId)
 {
     try
     {
         bool is_edit = BusinessService.ChangeActiveBusiness(bussiness.place_id, userId, bussiness.is_active);
         if (!is_edit)
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound, "There is no business id as this in db"));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, "The business was active"));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e));
     }
 }
Esempio n. 3
0
        //Edit businesses
        //Input: bussinessDTO
        //Output: boolean if succeed or not
        public static bool EditBusiness(bussinessDTO business)
        {
            SwapDbConnection db = new SwapDbConnection();
            business         business_to_edit = db.businesses.FirstOrDefault(b => b.business_owner_id == business.business_owner_id && b.place_id == business.place_id);

            if (business_to_edit == null)
            {
                return(false);
            }

            business_to_edit.place.description = business.place_info.description ?? business_to_edit.place.description;
            business_to_edit.place.name        = business.place_info.name ?? business_to_edit.place.name;
            business_to_edit.opening_hours     = business.opening_hours ?? business_to_edit.opening_hours;
            business_to_edit.closing_hours     = business.closing_hours ?? business_to_edit.closing_hours;
            db.SaveChanges();

            return(true);
        }
Esempio n. 4
0
 public HttpResponseMessage RemoveBusiness([FromBody] bussinessDTO bussiness, string userId)
 {
     try
     {
         if (bussiness.place_id != null)
         {
             bool is_deleted = BusinessService.DeleteBusiness(userId, bussiness.place_id);
             if (!is_deleted)
             {
                 return(Request.CreateResponse(HttpStatusCode.NotFound, "There is no business id as this in db"));
             }
             return(Request.CreateResponse(HttpStatusCode.OK, "The bussiness is removed"));
         }
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "There missing prames"));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e));
     }
 }