Exemple #1
0
 public MyPlayer()
 {
     MaxHealth  = Health = DEFAULT_PLAYER_MAX_HEALTH;
     Statistics = new MyPlayerStatistics();
     Faction    = MyMwcObjectBuilder_FactionEnum.Rainiers;
     Medicines  = MyMedicine.GetArrayOfAllMedicines();
 }
Exemple #2
0
 public ActionResult Create(MyMedicine list)
 {
     try
     {
         long count = 0;
         if (db.MyMedicines.Any())
         {
             count = db.MyMedicines.Max(m => m.MedicineID);
             count++;
         }
         else
         {
             count = 1000;
         }
         var    file = Request.Files["file"];
         string name = "";
         if (file.ContentLength > 0)
         {
             string extension = System.IO.Path.GetExtension(file.FileName);
             name = Convert.ToString(count) + extension;
             string pic  = System.IO.Path.GetFileName(file.FileName);
             string path = System.IO.Path.Combine(Server.MapPath("~/Uploads/MyMedicines"), name);
             file.SaveAs(path);
             list.Images = name;
         }
         string role = Convert.ToString(Session["RoleName"]);
         if (role == "Admin")
         {
             if (list.MedicineName == "" || list.MedicineName == null)
             {
                 int helper = Convert.ToInt32(list.HelperID);
                 ViewBag.HelperID = new SelectList(db.Registrations.Where(m => m.Role != "Admin"), "UserID", "UserName", list.HelperID);
                 ViewBag.UserID   = new SelectList(db.UserRegistrations.Where(m => m.HelperID == helper), "UserID", "UserName");
                 return(View());
             }
         }
         if (ModelState.IsValid)
         {
             if (list.HelperID <= 0 || list.HelperID == null)
             {
                 list.HelperID = Convert.ToInt32(Session["UserID"]);
             }
             db.MyMedicines.Add(list);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(list));
     }
     catch
     {
         return(View(list));
     }
 }
Exemple #3
0
 // GET: MyMedicine/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         MyMedicine lst = db.MyMedicines.Find(id);
         db.MyMedicines.Remove(lst);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
Exemple #4
0
 public ActionResult Edit(MyMedicine list)
 {
     try
     {
         int    user = Convert.ToInt32(Session["listuser"]);
         string role = Convert.ToString(Session["RoleName"]);
         var    file = Request.Files["file"];
         string name = "";
         if (file.ContentLength > 0)
         {
             string extension = System.IO.Path.GetExtension(file.FileName);
             name = Convert.ToString(list.MedicineID) + extension;
             string pic  = System.IO.Path.GetFileName(file.FileName);
             string path = System.IO.Path.Combine(Server.MapPath("~/Uploads/MyMedicines"), name);
             file.SaveAs(path);
             list.Images = name;
         }
         else
         {
             list.Images = Convert.ToString(list.Images);
         }
         if (role == "Admin")
         {
             if (user != list.HelperID)
             {
                 int helper = Convert.ToInt32(list.HelperID);
                 ViewBag.HelperID    = new SelectList(db.Registrations, "UserID", "UserName", list.HelperID);
                 ViewBag.UserID      = new SelectList(db.UserRegistrations.Where(m => m.HelperID == helper), "UserID", "UserName");
                 Session["listuser"] = list.HelperID;
                 return(View(list));
             }
         }
         if (ModelState.IsValid)
         {
             db.Entry(list).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(list));
     }
     catch
     {
         return(View(list));
     }
 }