示例#1
0
        public async Task <OperationResponse <PartyDetail> > UpdateAsync(PartyDetail model)
        {
            var party = await _unitOfWork.Parties.GetByIdAsync(model.Id);

            if (party == null)
            {
                return new OperationResponse <PartyDetail>
                       {
                           IsSuccess = false,
                           Data      = null,
                           Message   = "Party not found"
                       }
            }
            ;

            party.Name = model.Name;


            await _unitOfWork.CommitChangesAsync(_identity.UserId);

            return(new OperationResponse <PartyDetail>
            {
                IsSuccess = true,
                Message = "Party has been updated successfully!",
                Data = model
            });
        }
示例#2
0
        public async Task <IActionResult> Update(PartyDetail model)
        {
            var result = await _partiesService.UpdateAsync(model);

            if (result.IsSuccess)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
示例#3
0
        public async Task <OperationResponse <PartyDetail> > CreateAsync(PartyDetail model)
        {
            var party = new Party
            {
                Name       = model.Name,
                VotelistId = model.VotelistId
            };

            await _unitOfWork.Parties.CreateAsync(party);

            await _unitOfWork.CommitChangesAsync(_identity.UserId);

            model.Id = party.Id;

            return(new OperationResponse <PartyDetail>
            {
                IsSuccess = true,
                Message = "Party created successfully!",
                Data = model
            });
        }