コード例 #1
0
 public ActionResult Create(TeamMember team)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var obj = new FileUploadHelper();
             var filename = obj.SaveImages();
             if (filename == obj.ErrorMessage)
             {
                 ModelState.AddModelError("ImageUpload Error", filename);
                 return View(team);
             }
             team.ImageUrl = filename;
             ObjTeamMemberService.Add(team);
             return RedirectToAction("Index");
         }
         else
         {
             return View(team);
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Error", ex.Message);
         return View(team);
     }
 }
コード例 #2
0
 public ActionResult Create(Products model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var obj = new FileUploadHelper();
             var filename = obj.SaveImages();
             if (filename == obj.ErrorMessage)
             {
                 ModelState.AddModelError("ImageUpload Error", filename);
                 return View(model);
             }
             model.ImageUrl = filename;
             ObjProductService.Add(model);
             return RedirectToAction("Index");
         }
         else
         {
             return View(model);
         }
     }
     catch
     {
         return View();
     }
 }
コード例 #3
0
 public ActionResult Edit(int id, Customer customer)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var obj = new FileUploadHelper();
             var filename = obj.SaveImages();
             if (filename == obj.ErrorMessage)
             {
                 ModelState.AddModelError("ImageUpload Error", filename);
                 return View(customer);
             }
             customer.ImageUrl = filename;
             CustomerService.Add(customer);
             return RedirectToAction("Index");
         }
         return View(customer);
     }
     catch(Exception ex)
     {
         ModelState.AddModelError("Error", ex.Message);
         return View();
     }
 }