Example #1
0
        public ActionResult Delete(CreateRecipientViewModel model)
        {
            var delRecipient = recipientRepo.ResultTable.Where(i => i.Id == model.RecipientId).First();
            var delAddress   = addressRepo.ResultTable.Where(i => i.Id == delRecipient.AddressId).First();

            recipientRepo.Delete(delRecipient);
            addressRepo.Delete(delAddress);

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Edit(CreateRecipientViewModel model)
        {
            var currRecipient = recipientRepo.ResultTable.Where(i => i.Id == model.RecipientId).First();
            var currAddress   = addressRepo.ResultTable.Where(i => i.Id == currRecipient.AddressId).First();

            currRecipient.OrganizationName = model.OrganizationName;
            currRecipient.Description      = model.Description;
            currAddress.Address1           = model.Address1;
            currAddress.Address2           = model.Address2;
            currAddress.City  = model.City;
            currAddress.State = model.State;
            currAddress.Zip   = model.Zip;

            recipientRepo.Save(currRecipient);
            addressRepo.Save(currAddress);

            return(RedirectToAction("Details", new { id = model.RecipientId }));
        }
Example #3
0
        private CreateRecipientViewModel GetModelWithRecipientId(int recipientId)
        {
            var currRecipient = recipientRepo.ResultTable.Where(i => i.Id == recipientId).First();
            var currAddress   = addressRepo.ResultTable.Where(i => i.Id == currRecipient.AddressId).First();

            var model = new CreateRecipientViewModel();

            model.Address1           = currAddress.Address1;
            model.Address2           = currAddress.Address2;
            model.City               = currAddress.City;
            model.State              = currAddress.State;
            model.Zip                = currAddress.Zip;
            model.OrganizationName   = currRecipient.OrganizationName;
            model.Description        = currRecipient.Description;
            model.AddressId          = currAddress.Id;
            model.OrganizationTypeId = currRecipient.OrganizationTypeId;
            model.UserId             = currRecipient.UserId;
            model.RecipientId        = recipientId;

            return(model);
        }
Example #4
0
        public ActionResult Create(CreateRecipientViewModel model)
        {
            var newRecipient = new ServiceRecipient();
            var newAddress   = new Address();

            newAddress.Address1 = model.Address1;
            newAddress.Address2 = model.Address2;
            newAddress.City     = model.City;
            newAddress.State    = model.State;
            newAddress.Zip      = model.Zip;

            addressRepo.Save(newAddress);

            newRecipient.AddressId          = newAddress.Id;
            newRecipient.OrganizationName   = model.OrganizationName;
            newRecipient.Description        = model.Description;
            newRecipient.OrganizationTypeId = 5;
            newRecipient.UserId             = User.Identity.GetUserId();

            recipientRepo.Save(newRecipient);

            return(RedirectToAction("Details", new { id = newRecipient.Id }));
        }
Example #5
0
        // GET: ServiceRecipient/Create
        public ActionResult Create()
        {
            var model = new CreateRecipientViewModel();

            return(View(model));
        }