예제 #1
0
        public ActionResult Add()
        {
            AreaOFInterest  AOI    = new AreaOFInterest();
            AreaOfInterest2 model2 = new AreaOfInterest2();

            return(View(model2));
        }
예제 #2
0
 public ActionResult Add(AreaOfInterest2 model, HttpPostedFileBase image1)
 {
     try
     {
         AreaOFInterest model2 = new AreaOFInterest();
         var            db     = new Entities();
         if (ModelState.IsValid)
         {
             if (image1 != null)
             {
                 string ext = Path.GetExtension(image1.FileName).ToUpper();
                 if (ext == ".PNG" || ext == ".JPG" || ext == ".JPEG")
                 {
                     model2.AOIIcon = new byte[image1.ContentLength];
                     image1.InputStream.Read(model2.AOIIcon, 0, image1.ContentLength);
                     model2.AOIName = model.AOIName;
                     db.AreaOFInterests.Add(model2);
                     db.SaveChanges();
                     return(Content("<script language='javascript' type='text/javascript'>alert('New area of interest added successfully');window.location = '/AreaOfInterest/AOIAdmin/';</script>"));
                     //return RedirectToAction("AOIAdmin");
                 }
                 else
                 {
                     ViewBag.ErrorMessage = "The icon should be .png or .jpg or .jpeg";
                 }
             }
             else
             {
                 ViewBag.ErrorMessages = "Upload icon of area of interest";
             }
         }
         return(View(model));
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "AreaOfInterest", "Add")));
     }
 }