static public HttpResponseMessage AddCarService(DataModels.CarServiceModel NewService)
        {
            var db          = new ITAPPCarWorkshopServiceDBEntities();
            var returnValue = new HttpResponseMessage(HttpStatusCode.Forbidden);

            returnValue.Content = new StringContent("Service with this name is already exists");
            var CarExists = db.Car_Services.FirstOrDefault(car => car.Service_name == NewService.ServiceName);

            if (CarExists != null)
            {
                return(returnValue);
            }
            mutex.WaitOne();
            db.Car_Services.Add(NewService.MakeEntityFromModel());
            db.SaveChanges();
            mutex.ReleaseMutex();
            returnValue         = new HttpResponseMessage(HttpStatusCode.OK);
            returnValue.Content = new StringContent("Service was added");
            return(returnValue);
        }
        static public HttpResponseMessage ModifyCarService(DataModels.CarServiceModel ModifyService)
        {
            var db          = new ITAPPCarWorkshopServiceDBEntities();
            var returnValue = new HttpResponseMessage(HttpStatusCode.Forbidden);

            returnValue.Content = new StringContent("Service with this name not exsists");
            var OldCar = db.Car_Services.FirstOrDefault(car => car.Service_ID == ModifyService.ServiceID);

            if (OldCar != null)
            {
                var ID = OldCar.Service_ID;
                OldCar            = ModifyService.MakeEntityFromModel();
                OldCar.Service_ID = ID;
                mutex.WaitOne();
                db.SaveChanges();
                mutex.ReleaseMutex();
                returnValue         = new HttpResponseMessage(HttpStatusCode.Accepted);
                returnValue.Content = new StringContent("Service was modifiy");
                return(returnValue);
            }
            return(returnValue);
        }
예제 #3
0
 public HttpResponseMessage Change_Car_Service([FromBody] DataModels.CarServiceModel Modifi_car)
 {
     return(ModelsManager.CarServiceMenager.ModifyCarService(Modifi_car));
 }
예제 #4
0
 public HttpResponseMessage Add_Car_Service([FromBody] DataModels.CarServiceModel New_Car_Profile)
 {
     return(ModelsManager.CarServiceMenager.AddCarService(New_Car_Profile));
 }