Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "Id,Days,Filled,FullName,Price,Currency,BrokenDevice,BuySomeDetailsYourself,AdditionalRequests")] DBRemontModel dbRemontModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dbRemontModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dbRemontModels));
 }
Exemplo n.º 2
0
        // GET: DB/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DBRemontModel dbRemontModel = db.RemontModels.Find(id);

            if (dbRemontModel == null)
            {
                return(HttpNotFound());
            }
            return(View(dbRemontModel));
        }
Exemplo n.º 3
0
        public ActionResult Print(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                var dto = Remont.RideDtoHelper.LoadFromStream(file.InputStream);

                using (var db = new ApplicationDbContext())
                {
                    var row = new DBRemontModel
                    {
                        Days                   = dto.TimeOfRepair.Days,
                        Filled                 = dto.TimeOfRepair.Filled,
                        FullName               = dto.FullName,
                        Price                  = dto.Price.Price,
                        Currency               = (Models.Currency)(int) dto.Price.Currency,
                        BrokenDevice           = (Models.Apparat)(int) dto.DescriptionOfBreakageDevice.BrokenDevice,
                        BuySomeDetailsYourself = dto.Repair.BuySomeDetailsYourself,
                        AdditionalRequests     = dto.Repair.AdditionalRequests,
                    };

                    row.Breakages = new Collection <DBBreakage>();

                    foreach (var brDto in dto.DescriptionOfBreakageDevice.Breakage)
                    {
                        row.Breakages.Add(new DBBreakage
                        {
                            BreakageType = (Models.DamageType)(int) brDto.BreakageType,
                            Description  = brDto.Description
                        });
                    }

                    db.RemontModels.Add(row);
                    db.SaveChanges();
                }

                return(View(dto));
            }

            return(RedirectToAction("Index"));
        }