Ejemplo n.º 1
0
        public ActionResult EditPost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var userToUpdate = nomadDB.Users.Find(id);

            if (TryUpdateModel(userToUpdate, "",
                               new string[] { "Name", "Surname", "Info", "Language", "GenderID", "Telephone", "Whatsapp", "Country" }))
            {
                try
                {
                    nomadDB.SaveChanges();

                    return(RedirectToAction("Details", new { id = userToUpdate.ID }));
                }
                catch (Exception /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            return(View(userToUpdate));
        }
Ejemplo n.º 2
0
        public ActionResult Register(RegisterModel user)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    User u = new User();
                    u.Name     = user.Name;
                    u.Surname  = user.Surname;
                    u.Email    = user.Email;
                    u.Password = user.Password;
                    u.Gender   = user.Gender;
                    u.Birth    = user.Birthday;
                    u.Country  = user.Country;
                    if (u.Gender == "Male")
                    {
                        u.Image = "male.png";
                    }
                    else
                    {
                        u.Image = "female.png";
                    }
                    nomadDB.Users.Add(u);
                    nomadDB.SaveChanges();

                    //return RedirectToAction("Registered");
                    return(RedirectToAction("Index", "Home"));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(user));
        }
Ejemplo n.º 3
0
 public void Post([FromBody] Festival fest)
 {
     nomadDB.Festivals.Add(fest);
     nomadDB.SaveChanges();
 }
Ejemplo n.º 4
0
        public ActionResult Create(VMFestival item)
        {
            try
            {
                Festival fest = new Festival();

                fest.Name        = item.Name;
                fest.About       = item.About;
                fest.Short       = item.Short;
                fest.Region      = item.Region;
                fest.City        = item.City;
                fest.Price       = item.Price;
                fest.Province    = item.Province;
                fest.Organizator = item.Organizator;
                fest.Address     = item.Address;
                fest.Date1       = item.Date1;
                fest.Date2       = item.Date2;

                var identity = (System.Web.HttpContext.Current.User as Nomaddoors.MyPrincipal).Identity as Nomaddoors.MyIdentity;
                fest.Guide = identity.User.ID;



                nomadDB.Festivals.Add(fest);
                nomadDB.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }