Example #1
0
 public ActionResult Edit([Bind(Include = "NeedHelpId,FirstName,LastName,Email,Phone,Message")] NeedHelp needHelp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(needHelp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(needHelp));
 }
 public ActionResult Edit([Bind(Include = "CanHelpId,FirstName,LastName,Email,CreditCard,CV,Amount")] CanHelp canHelp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(canHelp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DonateConfirmed", new { id = canHelp.CanHelpId }));
     }
     return(View(canHelp));
 }
Example #3
0
        public override async Task <UpdateCharityResponse> Handle(UpdateCharityRequest message)
        {
            var charity = await _context.Charities.FirstOrDefaultAsync(u => u.CharityKey == message.CharityKey);

            if (charity == null)
            {
                return(Error(ErrorType.NotFound));
            }

            _context.Entry(charity).CurrentValues.SetValues(message);

            if (await _context.TrySaveChangesAsync())
            {
                await _bus.PublishAsync(_mapper.Map <CharityUpdatedEvent>(charity));

                return(Success());
            }

            return(Error(ErrorType.DatabaseError));
        }
        public async Task <UpdateCharityResponse> Handle(UpdateCharityRequest message)
        {
            var charity = await _context.Charities.FirstOrDefaultAsync(u => u.CharityKey == message.CharityKey);

            if (charity == null)
            {
                return(new UpdateCharityResponse
                {
                    ErrorType = ErrorType.NotFound
                });
            }

            _context.Entry(charity).CurrentValues.SetValues(message);
            if (!await _context.TrySaveChangesAsync())
            {
                return(new UpdateCharityResponse());
            }

            var charityUpdatedEvent = _mapper.Map <CharityUpdatedEvent>(charity);
            await _bus.PublishAsync(charityUpdatedEvent);

            return(UpdateCharityResponse.Success());
        }