public ResultAction Put(ProposalDTO proposal) { ResultAction result = new ResultAction(); int row = 0; using (var scope = new TransactionScope()) { if (proposal.Id != null) { row = new ProposalService().Put(proposal); if (row > 0) { CreateHistory(proposal.IdUser.Value, proposal.Id.Value, ActionHistoric.Edited); result.IsOk = true; result.Result = row; } else { result.Message = "Erro ao atualizar a proposta."; } } else { result.Message = "Proposta não encontrada."; } scope.Complete(); scope.Dispose(); } return(result); }
public IHttpActionResult PutProposal(ProposalDTO updatedProposal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var proposal = Mapper.Map <Proposal>(updatedProposal); _proposalService.UpdateProposal(proposal); try { _proposalService.SaveProposal(); } catch (DbUpdateConcurrencyException) { if (!_proposalService.ProposalExists(proposal.ID)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ReviewProposal(ClientController ctr, ProposalDTO proposal, int reviewerId) { this.ctrl = ctr; this.proposal = proposal; this.reviewerId = reviewerId; InitializeComponent(); }
public UpdateProposal(ClientController ctrl, ProposalDTO prop, MyProposals win) { this.ctrl = ctrl; this.proposal = prop; this.window = win; InitializeComponent(); }
public async Task <ActionResult> Create(ProposalDTO newProposal) { if (ModelState.IsValid) { var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("ID", Guid.NewGuid().ToString()), new KeyValuePair <string, string>("ClientID", User.Identity.Name), new KeyValuePair <string, string>("Distance", newProposal.Distance.ToString()), new KeyValuePair <string, string>("HasPiano", newProposal.HasPiano.ToString()), new KeyValuePair <string, string>("IsAccepted", bool.FalseString), new KeyValuePair <string, string>("Volume", newProposal.Volume.ToString()), new KeyValuePair <string, string>("ProposalDate", DateTime.Now.ToString()), new KeyValuePair <string, string>("Price", newProposal.Price.ToString()) }); using (_httpClient = new HttpClient()) { HttpResponseMessage response = await _httpClient.PostAsync(new Uri($"{_apiPath}{_proposalApi}"), content); } return(RedirectToAction("Index")); } else { return(View(newProposal)); } }
public ManageAuthors(ClientController ctr, ProposalDTO prop, MyProposals win) { this.ctr = ctr; this.prop = prop; this.window = win; InitializeComponent(); }
public async ValueTask <List <long> > GetUsersIdByRegion(long chatid) { List <long> result = new List <long>(); ProposalDTO proposal = await proposalRepository.Get().FirstOrDefaultAsync(i => i.ChatId == chatid); string region = ""; if (proposal != null) { if (proposal.RealAddress != null) { int index = proposal.RealAddress.IndexOf(",") + 2; int lastindex = proposal.RealAddress.IndexOf(",", index + 1); for (int i = index; i < lastindex; i++) { region += proposal.RealAddress[i]; } } } result = await proposalRepository.Get().Where(i => i.RealAddress.IndexOf(region) != -1). Select(p => p.ChatId) .ToListAsync(); return(result); }
public async Task MessageAboutRegistrationPilot(TelegramBotClient client, ServiceProvider provider, long chatid) { int countAdmin = await provider.adminService.CountAdmins(); if (countAdmin == 0) { return; } List <long> admins = await provider.adminService.GetChatId(); ProposalDTO proposal = await provider.proposalService.FindById(chatid); int numberOfPurpost = await propose.GetCount(); UserDTO user = await provider.userService.FindUserByPredicate(i => i.ChatId == proposal.ChatId); if (user == null) { throw new System.Exception("user is null"); } string message = $"Pilots: {propose.GetCount()}\n" + $"Pilot №{proposal.ChatId} is registered\n " + $"Name:{user.FIO}\n " + $"Tel.:{user.Phone}\n " + $"Insurance:{proposal.TypeOfInsurance}\n " + $"Address:{proposal.Address}\n " + $"Address, geolocation:{proposal.RealAddress}"; admins.ForEach(async(item) => { await client.SendTextMessageAsync(item, message); }); }
public IHttpActionResult PostProposal(ProposalDTO dtoProposal) { var client = _clientService.GetClient(dtoProposal.Email); var proposal = Mapper.Map <Proposal>(dtoProposal); proposal.ClientID = client.ID; _proposalService.CreateProposal(proposal); try { _proposalService.SaveProposal(); } catch (DbUpdateException) { if (!_proposalService.ProposalExists(proposal.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = dtoProposal.ID }, dtoProposal)); }
public void UpdateProposal(ProposalDTO proposal) { try { _proposalRepository.UpdatePropsal(proposal); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Post([FromBody] ProposalDTO proposal) { using (_context) { _proposalRepository.Add(new Attendance.Proposals.Domain.DomainModels.Proposal(Guid.NewGuid(), 100, 5)); await _context.SaveChangesAsync(); return(Ok()); } }
private TransactionProposalDTO GetTransactionProposal(ProposalData proposal) { ProposalDTO propuestaDTO = new ProposalDTO() { Id = proposal.Id, Documento = proposal.Client.Documento, Payback = proposal.Payback, DevicePayment = proposal.DevicePayment, Subsidio = proposal.Subsidio, CreatedDate = DateTime.Now, Estado = "Pendiente", IdUsuario = proposal.IdUsuario, Activa = proposal.Activa }; if (proposal.Finalizada) { propuestaDTO.Estado = "Finalizada"; } var lineasDTO = new List <ProposalLineDTO>(); for (var i = 0; i < proposal.SuggestorList.Count; i++) { lineasDTO.Add(new ProposalLineDTO() { NumeroLinea = proposal.SuggestorList[i].Movil.ToString(), Plan = proposal.PlanesDefList[i].Plan, IdPropuesta = 0 }); } var equiposDTO = new List <ProposalDeviceDTO>(); foreach (DevicePymes equipo in proposal.MobileDevicesList) { equiposDTO.Add(new ProposalDeviceDTO() { IdPropuesta = 0, CODIGO_EQUIPO = equipo.CodigoEquipo }); } var transactionProposalDto = new TransactionProposalDTO() { Proposal = propuestaDTO, Lines = lineasDTO, MobileDevices = equiposDTO }; return(transactionProposalDto); }
public async Task <ActionResult> AcceptConfirmed(Guid id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProposalDTO proposal = new ProposalDTO(); using (_httpClient = new HttpClient()) { HttpResponseMessage response = await _httpClient.GetAsync($"{_apiPath}{_proposalApi}/{id}"); if (response.IsSuccessStatusCode) { proposal = await response.Content.ReadAsAsync <ProposalDTO>(); } } proposal.IsAccepted = true; proposal.AcceptanceDate = DateTime.Now; try { var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("ID", proposal.ID.ToString()), new KeyValuePair <string, string>("ClientID", proposal.ClientID.ToString()), new KeyValuePair <string, string>("Distance", proposal.Distance.ToString()), new KeyValuePair <string, string>("HasPiano", proposal.HasPiano.ToString()), new KeyValuePair <string, string>("IsAccepted", proposal.IsAccepted.ToString()), new KeyValuePair <string, string>("Volume", proposal.Volume.ToString()), new KeyValuePair <string, string>("ProposalDate", proposal.ProposalDate.ToString()), new KeyValuePair <string, string>("Price", proposal.Price.ToString()), new KeyValuePair <string, string>("AcceptanceDate", proposal.AcceptanceDate.ToString()) }); using (_httpClient = new HttpClient()) { HttpResponseMessage response = await _httpClient.PutAsync(new Uri($"{_apiPath}{_proposalApi}"), content); } return(RedirectToAction("Index")); } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } return(View(proposal)); }
public async Task <bool> UpdatePropsal(ProposalDTO proposal) { try { _context.Proposal.Update(proposal); _context.SaveChanges(); return(true); } catch (Exception ex) { throw ex; } }
private bool allowReview(ProposalDTO prop) { var reviews = _ctrl.getAllForProposal(prop.Id); foreach (var review in reviews) { if (review.ReviewerId == _user.Id) { return(false); } } return(true); }
public async ValueTask <bool> IsUserRegistration(long chatid) { ProposalDTO proposal = await proposalRepository.Get().FirstOrDefaultAsync(i => i.ChatId == chatid); if (proposal == null) { return(false); } if (proposal.longtitude.HasValue && proposal.latitude.HasValue) { return(true); } return(false); }
private async Task <int> AddProposal(ProposalDTO propuesta) { try { _context.Proposal.Update(propuesta); _context.SaveChanges(); var proposalId = propuesta.Id; return(proposalId); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> Specific(Guid id) { ProposalDTO carStatus = new ProposalDTO(); using (_httpClient = new HttpClient()) { HttpResponseMessage response = await _httpClient.GetAsync($"{_apiPath}{_proposalApi}/{id}"); if (response.IsSuccessStatusCode) { carStatus = await response.Content.ReadAsAsync <ProposalDTO>(); } return(View(carStatus)); } }
public ProposalDTO UpdatePaper(ProposalDTO paperDto) { using (var uow = new UnitOfWork()) { var paperRepo = uow.getRepository <Proposal>(); var paper = paperRepo.get(paperDto.Id); if (paper == null) { return(null); } paperRepo.update(paperDto.Id, _proposalConverter.convertToPOCOModel(paperDto)); uow.saveChanges(); return(_proposalConverter.convertToDTOModel(paperRepo.get(paperDto.Id))); } }
public void DeleteProposal(int proposalId) { try { var proposal = new ProposalDTO() { Id = proposalId, Activa = false }; _context.Proposal.Attach(proposal); _context.Entry(proposal).Property(x => x.Activa).IsModified = true; _context.SaveChanges(); } catch (Exception ex) { throw ex; } }
internal int Put(ProposalDTO proposal) { Proposal upd = context.Proposals.First(x => x.Id == proposal.Id.Value); int row = 0; if (upd != null) { upd.Description = proposal.Description; upd.IdCategory = proposal.IdCategory; upd.IdSupplier = proposal.IdSupplier; upd.Name = proposal.Name; upd.Value = proposal.Value; row = context.SaveChanges(); } return(row); }
public async ValueTask <List <long> > GetUsersIdByRegion(long chatid) { List <long> result = new List <long>(); ProposalDTO proposal = await proposalRepository.Get().FirstOrDefaultAsync(i => i.ChatId == chatid); if (proposal != null) { string region = proposal.Region; result = await proposalRepository.Get().Where(i => i.Region == region) .Select(p => p.ChatId) .ToListAsync(); } /* result = await proposalRepository.Get().Where(i => i.RealAdress.IndexOf(region) != -1). * Select(p => p.ChatId) * .ToListAsync();*/ return(result); }
public ProposalDTO AddPaper(int idUser, int idConferinta, ProposalDTO paperDto) { paperDto.ProposalState = ProposalState.Pending; var userConference = SearchUserConference(idUser, idConferinta); if (userConference == null) { return(null); } paperDto.ParticipationId = userConference.Id; using (var uow = new UnitOfWork()) { var paperRepo = uow.getRepository <Proposal>(); var paper = _proposalConverter.convertToPOCOModel(paperDto); var paperReturned = paperRepo.save(paper); uow.saveChanges(); return(_proposalConverter.convertToDTOModel(paperReturned)); } }
public virtual ProposalDTO Save([FromBody] ProposalDTO model) { Proposal proposal = string.IsNullOrEmpty(model.Id) ? new Proposal() : proposalService.GetById(model.Id); var mapper = new MapperConfiguration(cfg => { cfg.CreateMap <ProposalDTO, Proposal>().ForMember(m => m.ProposalDocuments, p => p.UseValue <List <ProposalDocument> >(null)); cfg.CreateMap <InstitutionDTO, Institution>(); cfg.CreateMap <ProposalDocumentDTO, ProposalDocument>(); }).CreateMapper(); mapper.Map(model, proposal); proposal.Institution = this.institutionService.GetById(proposal.Institution.Id); if (string.IsNullOrEmpty(proposal.Id)) { proposal.Id = string.IsNullOrEmpty(proposal.Id) ? Guid.NewGuid().ToString() : proposal.Id; proposalService.Add(proposal); } if (model.ProposalDocuments != null) { foreach (ProposalDocumentDTO doc in model.ProposalDocuments) { ProposalDocument targetDoc = null; if (!string.IsNullOrEmpty(doc.Id)) { targetDoc = proposal.ProposalDocuments.FirstOrDefault(d => d.Id == doc.Id); } else { targetDoc = new ProposalDocument(); } mapper.Map <ProposalDocumentDTO, ProposalDocument>(doc, targetDoc); proposal.ProposalDocuments.Add(targetDoc); } proposal.ProposalDocuments.ForEach(d => { d.Id = string.IsNullOrEmpty(d.Id) ? Guid.NewGuid().ToString() : d.Id; }); } proposalService.Save(); mapper = new MapperConfiguration(cfg => { cfg.CreateMap <Proposal, ProposalDTO>(); cfg.CreateMap <Institution, InstitutionDTO>(); cfg.CreateMap <ProposalDocument, ProposalDocumentDTO>(); }).CreateMapper(); return(mapper.Map <ProposalDTO>(proposal)); }
internal ResultAction Post(ProposalDTO proposal) { ResultAction result = new ResultAction(); using (var scope = new TransactionScope()) { Proposal newProposal = new Proposal(); newProposal.ExpirationDate = GetExpirationDate(newProposal.CreationDate); newProposal.Description = proposal.Description; newProposal.IdCategory = proposal.IdCategory; newProposal.IdSupplier = proposal.IdSupplier; newProposal.Name = proposal.Name; newProposal.NameFile = proposal.NameFile; newProposal.Status = Status.Registred; newProposal.StatusNow = StatusNow.Registred; newProposal.Value = proposal.Value; int id = new ProposalService().Post(newProposal); if (id > 0) { CreateHistory(proposal.IdUser.Value, id, ActionHistoric.Registred); result.IsOk = true; result.Result = id; result.Message = "Proposta salva com sucesso."; } else { result.Message = "Erro ao criar uma nova proposta."; } scope.Complete(); scope.Dispose(); } return(result); }
public async Task <ActionResult> Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProposalDTO proposal = new ProposalDTO(); using (_httpClient = new HttpClient()) { HttpResponseMessage response = await _httpClient.GetAsync($"{_apiPath}{_proposalApi}/{id}"); if (response.IsSuccessStatusCode) { proposal = await response.Content.ReadAsAsync <ProposalDTO>(); } } if (proposal == null) { return(HttpNotFound()); } return(View(proposal)); }
public async Task MessageAboutRegistrationPilot(TelegramBotClient client, ServiceProvider provider, long chatid) { int countAdmin = await provider.adminService.CountAdmins(); if (countAdmin == 0) { return; } List <long> admins = await provider.adminService.GetChatId(); ProposalDTO proposal = await provider.proposalService.FindById(chatid); int numberOfPurpost = await propose.GetCount(); UserDTO user = await provider.userService.FindUserByPredicate(i => i.ChatId == proposal.ChatId); if (user == null) { throw new System.Exception("user is null"); } string message = $"Количество пилотов:{propose.GetCount()}\n" + $"Пилот №{proposal.ChatId} зарегистрировался\n " + $"ФИО:{user.FIO}\n " + $"Номер телефона:{user.Phone}\n " + $"Тип страховки:{proposal.TypeOfInsurance}\n " + $"Адрес доставки:{proposal.Adress}\n " + $"Адрес определенный с геопозиции:{proposal.RealAdress}"; admins.ForEach(async(item) => { await client.SendTextMessageAsync(item, message); }); }
public ProposalDTO UpdatePaper(ProposalDTO paperDto) { return(_proposalService.UpdatePaper(paperDto)); }
//methods from PaperService public ProposalDTO AddPaper(int idUser, int idConferinta, ProposalDTO paperDto) { return(_proposalService.AddPaper(idUser, idConferinta, paperDto)); }
public ViewReviewsForProposal(ClientController controller, ProposalDTO proposal) { _ctrl = controller; _proposal = proposal; InitializeComponent(); }