예제 #1
0
        public async Task <ActionResult <TireType> > PostTireType(TireType tireType)
        {
            _context.TireType.Add(tireType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTireType", new { id = tireType.Id }, tireType));
        }
예제 #2
0
        public async Task <IActionResult> PutTireType(int id, TireType tireType)
        {
            if (id != tireType.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tireType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TireTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        /// <summary>
        /// this should be in vehicle service
        /// </summary>
        /// <returns></returns>
        private List <Tire> GenerateTires(TireType tireType, TireStatus tireStatus)
        {
            int numberOfTires = 4;
            var tires         = new List <Tire>();

            if (tireType == TireType.Motor)
            {
                numberOfTires = 2;
            }
            else if (tireType == TireType.Truck)
            {
                numberOfTires = 6;
            }

            for (int i = 1; i <= numberOfTires; i++)
            {
                tires.Add(new Tire
                {
                    Name           = "Tire " + i,
                    Status         = tireStatus,
                    SelectedStatus = (int)tireStatus,
                    Type           = tireType
                }
                          );
            }

            return(tires);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TireType tireType = db.TireTypes.Find(id);

            db.TireTypes.Remove(tireType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
        public TireType GetById(int id)
        {
            TireType item = (from tt in Context.TireType
                             where tt.Id == id
                             select tt
                             ).FirstOrDefault();

            return(item);
        }
예제 #6
0
        public Response Update(TireType tireType)
        {
            var tireTypeToUpdate = GetById(tireType.Id);

            tireTypeToUpdate.Name = tireType.Name;
            Context.SaveChanges();

            return(Response.Success("Tekerlek tipi başarıyla güncellendi."));
        }
예제 #7
0
        public CarBuilder Init(string color, EngineType engine, TireType tires, decimal zeroTo60Time, decimal weight)
        {
            _color        = color;
            _engine       = engine;
            _tires        = tires;
            _zeroTo60Time = zeroTo60Time;
            _weight       = weight;

            return(this);
        }
예제 #8
0
파일: TireSet.cs 프로젝트: shakuu/Exams
 public TiresSet(
     decimal price,
     int weight,
     int topSpeed,
     int acceleration,
     TunningGradeType gradeType,
     TireType TireType)
     : base(price, weight, acceleration, topSpeed)
 {
 }
 public ActionResult Edit([Bind(Include = "TireID,TireSize,Tubeless")] TireType tireType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tireType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tireType));
 }
        public ActionResult Create([Bind(Include = "TireID,TireSize,Tubeless")] TireType tireType)
        {
            if (ModelState.IsValid)
            {
                db.TireTypes.Add(tireType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tireType));
        }
예제 #11
0
 public TiresSet(decimal price, int weight,
                 int acceleration, int topSpeed, TunningGradeType tunningGrade,
                 TireType tireType)
 {
     this.Price        = price;
     this.Weight       = weight;
     this.Acceleration = acceleration;
     this.TopSpeed     = topSpeed;
     this.GradeType    = tunningGrade;
     this.TireType     = tireType;
 }
예제 #12
0
        public Response Add(TireType tire)
        {
            Response checkadd = CheckToAddOrUpdate(tire);

            if (!checkadd.IsSuccess)
            {
                return(checkadd);
            }
            Context.TireType.Add(tire);
            Context.SaveChanges();
            return(Response.Succes("Ekleme İşlemi Başarılı"));
        }
예제 #13
0
 public ActionResult Create(TireType tireType)
 {
     try
     {
         var response = TireTypeService.Add(tireType);
         ViewBag.Response = response;
         return(View());
     }
     catch
     {
         return(View());
     }
 }
예제 #14
0
        private Response ChechToAddOrUpdate(TireType tireType)
        {
            int sameNumberOfRecords = (from t in Context.TireType
                                       where t.Name == tireType.Name && t.Id != tireType.Id
                                       select t
                                       ).Count();

            if (sameNumberOfRecords > 0)
            {
                return(Response.Fail($"{tireType.Name} lastik türü sistemde zaten kayıtlıdır."));
            }
            return(Response.Success());
        }
예제 #15
0
 public ActionResult Delete(TireType tire)
 {
     try
     {
         Response response = TireTypeService.Delete(tire);
         ViewBag.Response = response;
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
예제 #16
0
 public ActionResult Edit(TireType tire)
 {
     try
     {
         Response response = TireTypeService.Update(tire);
         ViewBag.Response = response;
         return(View());
     }
     catch
     {
         return(View());
     }
 }
예제 #17
0
        private Response CheckToAddOrUpdate(TireType tire)
        {
            int SameNumberOfRecords = (from b in Context.TireType
                                       where b.Name == tire.Name && b.Id != tire.Id
                                       select b
                                       ).Count();

            if (SameNumberOfRecords > 0)
            {
                return(Response.Fail($"{tire.Name} Lastik tipi sistemde zaten kayıtlıdır"));
            }
            return(Response.Succes());
        }
예제 #18
0
        public Response Update(TireType tire)
        {
            Response checkupdate = CheckToAddOrUpdate(tire);

            if (!checkupdate.IsSuccess)
            {
                return(checkupdate);
            }
            TireType UpdateToTire = GetById(tire.Id);

            UpdateToTire.Name = tire.Name;
            Context.SaveChanges();
            return(Response.Succes("Güncelleme İşlemi Başarılı"));
        }
예제 #19
0
        public Response Add(TireType tireType)
        {
            var chechResponse = ChechToAddOrUpdate(tireType);

            if (!chechResponse.IsSuccess)
            {
                return(chechResponse);
            }

            Context.TireType.Add(tireType);
            Context.SaveChanges();

            return(Response.Success("Lastik türü başarıyla kaydedildi"));
        }
예제 #20
0
 public TiresSet(
     decimal price,
     int weight,
     int acceleration,
     int topSpeed,
     TunningGradeType gradeType,
     TireType tireType)
     : base(price,
           weight,
           acceleration,
           topSpeed,
           gradeType)
 {
 }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TireType tireType = db.TireTypes.Find(id);

            if (tireType == null)
            {
                return(HttpNotFound());
            }
            return(View(tireType));
        }
예제 #22
0
 public ActionResult Create(TireType tireType)
 {
     try
     {
         var response = TireTypeService.Add(tireType);
         if (!response.IsSuccess)
         {
             ViewBag.Response = response;
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
예제 #23
0
        public Response Update(TireType tireType)
        {
            var checkResponse = ChechToAddOrUpdate(tireType);

            if (!checkResponse.IsSuccess)
            {
                return(checkResponse);
            }

            var tireTypeToUpdate = GetById(tireType.Id);

            tireTypeToUpdate.Name = tireType.Name;
            Context.SaveChanges();

            return(Response.Success("Lastik türü başarıyla güncellendi."));
        }
예제 #24
0
        // GET: TireTypeController/Delete/5
        public ActionResult Delete(int id)
        {
            TireType DeleteToTire = TireTypeService.GetById(id);

            return(View(DeleteToTire));
        }
예제 #25
0
 public Response Delete(TireType tire)
 {
     Context.TireType.Remove(tire);
     Context.SaveChanges();
     return(Response.Succes("Silme İşlemi Başarılı"));
 }
예제 #26
0
        // GET: TireTypeController/Edit/5
        public ActionResult Edit(int id)
        {
            TireType EditToTire = TireTypeService.GetById(id);

            return(View(EditToTire));
        }
예제 #27
0
 public Response Add(TireType tireType)
 {
     Context.TireType.Add(tireType);
     Context.SaveChanges();
     return(Response.Success("Tekerlek tipi başarıyla kaydedildi."));
 }
예제 #28
0
 protected TiresSet(decimal price, int weight, int acceleration, int topSpeed, TunningGradeType gradeType, TireType tyreType)
     : base(price, weight, acceleration, topSpeed, gradeType)
 {
     this.TireType = tyreType;
 }
예제 #29
0
 public CarBuilder ChangeTires(TireType tires)
 {
     _tires = tires;
     return(this);
 }
예제 #30
0
 public TireModel(TireType tireType)
 {
     this.TireTypeLevel = tireType;
 }