Esempio n. 1
0
 public async Task<ActionResult> DonatorRegistration(DonatorModel model) {
     ApplicationDbContext db = HttpContext.GetOwinContext().Get<ApplicationDbContext>();
     model.TotalDonations = 0;
     model.NumberOfDonations = 0;
     if(ModelState.IsValid) {
         model.usersAplication = UserManager.FindById(User.Identity.GetUserId());
         if(model.usersAplication != null) {
             model.Id = Guid.NewGuid().ToString();
             db.Donator.Add(model);
             UserManager.FindById(User.Identity.GetUserId()).FinishedRegistration = true;
             await db.SaveChangesAsync();
         }
     }
     return RedirectToAction("Index", "Manage");
 }
        public async Task<ActionResult> DonatorEdit(DonatorModel model) {
            if(!ModelState.IsValid) {
                return View();
            }

            var editModel = db.Donator.Where(d => d.Id.Equals(model.Id)).First();

            if(editModel == null) {
                return View();
            }

            editModel.Id = model.Id;
            editModel.MaticniBroj = model.MaticniBroj;
            editModel.OrganizationName = model.OrganizationName;
            editModel.street = model.street;
            editModel.City = model.City;
            editModel.Country = model.Country;
            editModel.usersAplication = editModel.usersAplication;

            await db.SaveChangesAsync();
            return RedirectToAction("DonatorsIndex");
        }