public async Task <BaseResponseDto <ComedianDto> > GetAsync(Guid Id) { BaseResponseDto <ComedianDto> getComedianResponse = new BaseResponseDto <ComedianDto>(); try { Comedian comedian = await _comedianRepository.GetAsync(Id); if (comedian != null) { getComedianResponse.Data = new ComedianDto { FirstName = comedian.FirstName, LastName = comedian.LastName, ContactPhone = comedian.ContactPhone, }; } else { getComedianResponse.Errors.Add("Comedian not found."); } } catch (Exception ex) { _logger.LogError(ex, ex.Message); getComedianResponse.Errors.Add(ex.Message); } return(getComedianResponse); }
public async Task <BaseResponseDto <ComedianDto> > DeleteComedian(Guid comedianId) { BaseResponseDto <ComedianDto> getComedianResponse = new BaseResponseDto <ComedianDto>(); try { if (comedianId != null) { Comedian comedian = await _comedianRepository.GetAsync(comedianId); await _comedianRepository.DeleteAsync(comedian); } else { getComedianResponse.Errors.Add("Comedian can't be delete."); } } catch (Exception ex) { _logger.LogError(ex, ex.Message); getComedianResponse.Errors.Add(ex.Message); } return(getComedianResponse); }
static void Main(string[] args) { OrchestraAbstractDecorator anchor = new Anchor(); OrchestraAbstractDecorator clown = new Clown(); OrchestraAbstractDecorator comedian = new Comedian(); OrchestraAbstractDecorator dancer = new Dancer(); OrchestraAbstractDecorator singer = new Singer(); while (true) { Console.WriteLine("Which package you want write \n F for free \n P for premium \n G for gold"); var input = Console.ReadLine().ToCharArray()[0]; Console.WriteLine(input.ToString()); switch (input) { case 'F': case 'f': Console.WriteLine("In free package you get Anchor and singer :)"); singer.orchestra = anchor; singer.play(); break; case 'P': case 'p': Console.WriteLine("In premium package you get Anchor, singer, dancer and comedian:)"); comedian.orchestra = dancer; dancer.orchestra = singer; singer.orchestra = anchor; comedian.play(); break; case 'G': case 'g': Console.WriteLine("In premium package you get Anchor, singer, dancer, comedian and clown:)"); clown.orchestra = comedian; comedian.orchestra = dancer; dancer.orchestra = singer; singer.orchestra = anchor; clown.play(); break; default: Console.WriteLine("whatever you selected you get an anchor : "); anchor.play(); break; } } }
public async Task <BaseResponseDto <ComedianDto> > CreateComedian(Comedian comedian) { BaseResponseDto <ComedianDto> getComedianResponse = new BaseResponseDto <ComedianDto>(); try { await _comedianRepository.CreateAsync(comedian); } catch (Exception ex) { _logger.LogError(ex, ex.Message); getComedianResponse.Errors.Add(ex.Message); } return(getComedianResponse); }
public async Task <BaseResponseDto <ComedianDto> > UpDateComedian(Guid comedianId, Comedian comedian) { BaseResponseDto <ComedianDto> getComedianResponse = new BaseResponseDto <ComedianDto>(); try { if (comedianId != null) { Comedian oldComedian = await _comedianRepository.GetAsync(comedianId); if (oldComedian != null) { oldComedian.FirstName = comedian.FirstName; oldComedian.LastName = comedian.LastName; oldComedian.ContactPhone = comedian.ContactPhone; oldComedian.ModifiedAt = DateTime.Now; //var comedianUpdate = _mapper.Map(comedian, oldComedian); await _comedianRepository.UpdateAsync(oldComedian); } else { return(null); } } else { getComedianResponse.Errors.Add("Comedian can't be update."); } } catch (Exception ex) { _logger.LogError(ex, ex.Message); getComedianResponse.Errors.Add(ex.Message); } return(getComedianResponse); }
public async Task <ActionResult <BaseResponseDto <ComedianDto> > > AddComedian(Comedian comedian) { BaseResponseDto <ComedianDto> newcomedian = await _comedianService.CreateComedian(comedian); if (!newcomedian.HasError || newcomedian.Data != null) { return(Ok(newcomedian.Data)); } else if (!newcomedian.HasError || newcomedian.Data == null) { return(NotFound()); } else { return(BadRequest(newcomedian.Errors)); } }
public async Task <ActionResult <string> > UpdateComedian([FromRoute] string id, Comedian comedian) { Guid _id = Guid.Parse(id); BaseResponseDto <ComedianDto> oldComedian = await _comedianService.UpDateComedian(_id, comedian); return(Ok("Comedian was update sucessfull")); }