public SingleResponeMessage <ProposalDetailInfo> Get(int id) { SingleResponeMessage <ProposalDetailInfo> ret = new SingleResponeMessage <ProposalDetailInfo>(); try { string _userID = GetUserId(); ProposalDetailInfo item = ProposalService.GetInstance().getDetailProposal(id, _userID); if (item == null) { ret.isSuccess = false; ret.err.msgCode = "001"; ret.err.msgString = "no proposal found"; return(ret); } ret.item = item; ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
internal ResultAction Delete(int id) { ResultAction result = new ResultAction(); using (var scope = new TransactionScope()) { int row = new ProposalService().Delete(id); if (row > 0) { result.IsOk = true; result.Result = row; result.Message = string.Empty; } else { result.Message = "Erro ao excluir a proposta."; } scope.Complete(); scope.Dispose(); } return(result); }
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 HttpResponseMessage Delete(int id) { ProposalService.Delete(id); SuccessResponse response = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
internal ResultAction Get() { List <ProposalDTO> proposals = new ProposalService().Get(); if (proposals.Any(x => x.Expireded && (Status)x.Status != Status.Approved && (Status)x.Status != Status.Disapproved)) { using (var scope = new TransactionScope()) { UpdateStatusExpired(proposals); scope.Complete(); scope.Dispose(); } } ResultAction result = new ResultAction(); if (proposals.Any()) { result.IsOk = true; result.Result = proposals.OrderBy(x => x.ExpirationDate).ToList(); } else { result.Message = "Nenhuma proposta encontrada."; } return(result); }
public HttpResponseMessage SelectById(int id) { ItemResponse <Proposal> response = new ItemResponse <Proposal>(); response.Item = ProposalService.SelectById(id); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage Post(ProposalAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = ProposalService.Post(model); ProposalSendRequest sendRequest = new ProposalSendRequest(); sendRequest.FirstName = model.FirstName; sendRequest.LastName = model.LastName; sendRequest.Email = model.Email; sendRequest.PhoneNumber = model.PhoneNumber; sendRequest.Deadline = model.Deadline; sendRequest.Budget = model.Budget; sendRequest.Company = model.Company; sendRequest.ProjectType = model.ProjectType; sendRequest.Description = model.Description; _emailService.SendProposalAdmin(sendRequest); ProposalSendRequest userRequest = new ProposalSendRequest(); userRequest.FirstName = model.FirstName; userRequest.LastName = model.LastName; userRequest.Email = model.Email; _emailService.SendProposalUser(userRequest); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public void TestServerServiceCreateAccount() { var userService = new UserService(); var userConferenceService = new UserConferenceService(); var adminConferenceService = new AdminConferenceService(); var proposalService = new ProposalService(); var reviewService = new ReviewService(); var ticketService = new TicketService(); var enumService = new EnumGetDataService(); var emailService = new EmailService(); var sectionService = new SectionService(); var serverService = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService); UserDTO userToAdd = new UserDTO() { Username = "******", Password = "******", FirstName = "User", LastName = "ForTest", Email = "*****@*****.**", WebPage = "test.ro", Admin = true, Validation = "Waiting" }; Assert.AreEqual(0, serverService.findAll().ToList().Count); var userSaved = serverService.createAccount(userToAdd); Assert.AreEqual(1, serverService.findAll().ToList().Count); Assert.AreEqual("UserForTest", serverService.findUser(userSaved.Id).Username); Assert.AreEqual("test.ro", userSaved.WebPage); }
public void TestServerServiceFindUser() { PrepareData(); var userService = new UserService(); var userConferenceService = new UserConferenceService(); var adminConferenceService = new AdminConferenceService(); var proposalService = new ProposalService(); var reviewService = new ReviewService(); var ticketService = new TicketService(); var enumService = new EnumGetDataService(); var emailService = new EmailService(); var sectionService = new SectionService(); var serverService = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService); var user1 = serverService.findUser(1); var user3 = serverService.findUser(3); Assert.AreEqual("User1", user1.Username); Assert.AreEqual("User3", user3.Username); Assert.AreEqual("Last1", user1.LastName); Assert.AreEqual("Last3", user3.LastName); Assert.AreEqual("First1", user1.FirstName); Assert.AreEqual("First3", user3.FirstName); Assert.AreEqual(true, user1.Admin); Assert.AreEqual(false, user3.Admin); }
public void TestServerServiceUpdateAccount() { var userService = new UserService(); var userConferenceService = new UserConferenceService(); var adminConferenceService = new AdminConferenceService(); var proposalService = new ProposalService(); var reviewService = new ReviewService(); var ticketService = new TicketService(); var enumService = new EnumGetDataService(); var emailService = new EmailService(); var sectionService = new SectionService(); var serverService = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService); PrepareData(); Assert.AreEqual(4, serverService.findAll().ToList().Count); var userForUpdate = serverService.findUser(1); userForUpdate.FirstName = "Pop"; userForUpdate.LastName = "Mihai"; userForUpdate.Username = "******"; var updatedUser = serverService.updateAccount(userForUpdate); var userFromDataBase = serverService.findUser(updatedUser.Id); Assert.AreEqual(4, serverService.findAll().ToList().Count); Assert.AreEqual("Pop", updatedUser.FirstName); Assert.AreEqual("Mihai", updatedUser.LastName); Assert.AreEqual("Updated", updatedUser.Username); Assert.AreEqual("Pop", userFromDataBase.FirstName); Assert.AreEqual("Mihai", userFromDataBase.LastName); Assert.AreEqual("Updated", userForUpdate.Username); }
public async System.Threading.Tasks.Task Execute(IJobExecutionContext context) { ProposalService ps = new ProposalService(); ps.VerificarPropuestasPorTerminar(); await Console.Error.WriteLineAsync("Error de la Tarea"); }
internal ResultAction Get(int id) { Proposal x = new ProposalService().Get(id); ResultAction result = new ResultAction(); if (x != null) { result.Result = new ProposalDTO { CreationDate = x.CreationDate, ExpirationDate = x.ExpirationDate, Description = x.Description, Id = x.Id, IdCategory = x.IdCategory, IdSupplier = x.IdSupplier, Name = x.Name, NameFile = x.NameFile, Status = (int)x.Status, StatusNow = (int)x.StatusNow, Value = x.Value }; result.IsOk = true; } else { result.Message = "Proposta não encontrada."; } return(result); }
public ProposalsController(DumkaDbContext context, AuthService authService, ProposalService proposalService, IMapper mapper) { _context = context; _authService = authService; _proposalService = proposalService; _mapper = mapper; }
public async Task <IActionResult> GetApproved() { // TODO: Authentication var approvedList = (await ProposalService.GetAll()).Where(x => x.State == ProposalState.Approved); return(Ok(approvedList)); }
public HttpResponseMessage SelectAll() { ItemsResponse <Proposal> response = new ItemsResponse <Proposal>(); response.Items = ProposalService.SelectAll(); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public async Task <IActionResult> GetAll() { // TODO: Authentication var list = await ProposalService.GetAll(); return(Ok(list)); }
public HttpResponseMessage Search([FromUri] ProposalSearchRequest model) { ItemsResponse <Proposal> response = new ItemsResponse <Proposal>(); response.Items = ProposalService.Search(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponse AcceptProposal(int id) { if (!User.IsInRole(Role.Administrator.ToString())) { return(new HttpResponse(HttpStatusCode.Forbidden)); } ProposalService.AcceptProposal(id); return(new HttpResponse(HttpStatusCode.Found).WithHeader("Location", ResolveUri.ForProposals())); }
/// <summary> /// Run the code example. /// </summary> public void Run(DfpUser user, long advertiserId, long buyerId, long primarySalespersonId, long primaryTraffickerId) { using (ProposalService proposalService = (ProposalService)user.GetService(DfpService.v201802.ProposalService)) using (NetworkService networkService = (NetworkService)user.GetService(DfpService.v201802.NetworkService)) { // Create a proposal. Proposal proposal = new Proposal(); proposal.name = "Programmatic proposal #" + new Random().Next(int.MaxValue); // Set the required Marketplace information. proposal.marketplaceInfo = new ProposalMarketplaceInfo() { buyerAccountId = buyerId }; proposal.isProgrammatic = true; // Create a proposal company association. ProposalCompanyAssociation proposalCompanyAssociation = new ProposalCompanyAssociation(); proposalCompanyAssociation.companyId = advertiserId; proposalCompanyAssociation.type = ProposalCompanyAssociationType.ADVERTISER; proposal.advertiser = proposalCompanyAssociation; // Create salesperson splits for the primary salesperson. SalespersonSplit primarySalesperson = new SalespersonSplit(); primarySalesperson.userId = primarySalespersonId; primarySalesperson.split = 100000; proposal.primarySalesperson = primarySalesperson; // Set the probability to close to 100%. proposal.probabilityOfClose = 100000L; // Set the primary trafficker on the proposal for when it becomes an order. proposal.primaryTraffickerId = primaryTraffickerId; // Create a budget for the proposal worth 100 in the network local currency. Money budget = new Money(); budget.microAmount = 100000000L; budget.currencyCode = networkService.getCurrentNetwork().currencyCode; proposal.budget = budget; try { // Create the proposal on the server. Proposal[] proposals = proposalService.createProposals(new Proposal[] { proposal }); foreach (Proposal createdProposal in proposals) { Console.WriteLine("A programmatic proposal with ID \"{0}\" and name \"{1}\" " + "was created.", createdProposal.id, createdProposal.name); } } catch (Exception e) { Console.WriteLine("Failed to create proposals. Exception says \"{0}\"", e.Message); } } }
public HttpResponse GetProposal(int id) { Proposal proposal = ProposalService.GetProposalById(id); if (proposal.User.Identity.Name.Equals(User.Identity.Name) || User.IsInRole(Role.Administrator.ToString())) { return(new HttpResponse(HttpStatusCode.OK, new ProposalView(proposal, GetUser()))); } return(new HttpResponse(HttpStatusCode.Forbidden)); }
public HttpResponse RejectProposal(int id) { Proposal proposal = ProposalService.GetProposalById(id); if (proposal.User.Identity.Name.Equals(proposal.User.Identity.Name) || User.IsInRole(Role.Administrator.ToString())) { ProposalService.RejectProposal(id); return(new HttpResponse(HttpStatusCode.Found).WithHeader("Location", ResolveUri.ForProposals())); } return(new HttpResponse(HttpStatusCode.Forbidden)); }
public HttpResponse NewProposal(IEnumerable <KeyValuePair <string, string> > content) { Show show = new Show { Name = content.GetValue("show_name") , Description = content.GetValue("show_description") }; Proposal proposal = ProposalService.AddProposal(show, GetUser()); return(new HttpResponse(HttpStatusCode.Found).WithHeader("Location", ResolveUri.For(proposal))); }
public HttpResponse EditProposalSubmit(IEnumerable <KeyValuePair <string, string> > content) { int proposalId = Convert.ToInt32(content.GetValue("proposal_id")); Proposal proposal = ProposalService.GetProposalById(proposalId); proposal.Show.Name = content.GetValue("show_name"); proposal.Show.Description = content.GetValue("show_description"); return(new HttpResponse(HttpStatusCode.Found).WithHeader("Location", ResolveUri.For(proposal))); }
internal int PutStatus(int?idUser, int idProposal, Status status, StatusNow statusNow, ActionHistoric action) { int row = new ProposalService().PutStatus(idProposal, status, statusNow); if (row > 0) { CreateHistory(idUser, idProposal, action); } return(row); }
public HttpResponseMessage Put(ProposalUpdateRequest model) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int?> response = new ItemResponse <int?>(); response.Item = ProposalService.Update(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
/// <summary> /// Run the code example. /// </summary> public void Run(DfpUser user) { using (ProposalService proposalService = (ProposalService)user.GetService(DfpService.v201805.ProposalService)) { long proposalId = long.Parse(_T("INSERT_PROPOSAL_ID_HERE")); // Create a statement to get the proposal. StatementBuilder statementBuilder = new StatementBuilder() .Where("id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", proposalId); try { // Get proposals by statement. ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.ToStatement()); Proposal proposal = page.results[0]; // Update the proposal object by changing its note. proposal.internalNotes = "Proposal needs further review before approval."; // Update the proposals on the server. Proposal[] proposals = proposalService.updateProposals(new Proposal[] { proposal }); if (proposals != null) { foreach (Proposal updatedProposal in proposals) { Console.WriteLine( "Proposal with ID = '{0}', name = '{1}', and notes = '{2}' was " + "updated.", updatedProposal.id, updatedProposal.name, updatedProposal.internalNotes); } } else { Console.WriteLine("No proposals updated."); } } catch (Exception e) { Console.WriteLine("Failed to update proposals. Exception says \"{0}\"", e.Message); } } }
/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user, long primarySalespersonId, long primaryTraffickerId, long programmaticBuyerId, long advertiserId) { using (ProposalService proposalService = user.GetService <ProposalService>()) { // Create a proposal with the minimum required fields. Proposal proposal = new Proposal() { name = "Programmatic proposal #" + new Random().Next(int.MaxValue), isProgrammatic = true, // Set required Marketplace information marketplaceInfo = new ProposalMarketplaceInfo() { buyerAccountId = programmaticBuyerId } }; // Set fields that are required before sending the proposal to the buyer. proposal.primaryTraffickerId = primaryTraffickerId; proposal.sellerContactIds = new long[] { primarySalespersonId }; proposal.primarySalesperson = new SalespersonSplit() { userId = primarySalespersonId, split = 100000 }; proposal.advertiser = new ProposalCompanyAssociation() { type = ProposalCompanyAssociationType.ADVERTISER, companyId = advertiserId }; try { // Create the proposal on the server. Proposal[] proposals = proposalService.createProposals(new Proposal[] { proposal }); foreach (Proposal createdProposal in proposals) { Console.WriteLine("A programmatic proposal with ID \"{0}\" " + "and name \"{1}\" was created.", createdProposal.id, createdProposal.name); } } catch (Exception e) { Console.WriteLine("Failed to create proposals. Exception says \"{0}\"", e.Message); } } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public void Run(DfpUser user, long proposalId) { ProposalService proposalService = (ProposalService)user.GetService(DfpService.v201608.ProposalService); // Create a statement to select Marketplace comments. StatementBuilder statementBuilder = new StatementBuilder() .Where("proposalId = :proposalId") .AddValue("proposalId", proposalId); // Retrieve a small amount of Marketplace comments at a time, paging through // until all Marketplace comments have been retrieved. MarketplaceCommentPage page = new MarketplaceCommentPage(); try { do { page = proposalService.getMarketplaceCommentsByStatement(statementBuilder.ToStatement()); if (page.results != null) { // Print out some information for each proposal. int i = page.startIndex; foreach (MarketplaceComment marketplaceComment in page.results) { Google.Api.Ads.Dfp.v201608.DateTime creationTime = marketplaceComment.creationTime; string isoTimestamp = new System.DateTime( day: creationTime.date.day, month: creationTime.date.month, year: creationTime.date.year, hour: creationTime.hour, minute: creationTime.minute, second: creationTime.second ).ToString("s"); Console.WriteLine("{0}) Marketplace comment with creation time \"{1}\" " + "and comment \"{2}\" was found.", i++, isoTimestamp, marketplaceComment.comment); } } statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.GetOffset() < page.totalResultSetSize); Console.WriteLine("Number of results found: {0}", page.totalResultSetSize); } catch (Exception e) { Console.WriteLine("Failed to get Marketplace comments. Exception says \"{0}\"", e.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public void Run(DfpUser dfpUser, long proposalId) { ProposalService proposalService = (ProposalService)dfpUser.GetService(DfpService.v201608.ProposalService); // Create a statement to select Marketplace comments. int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT; StatementBuilder statementBuilder = new StatementBuilder() .Where("proposalId = :proposalId") .AddValue("proposalId", proposalId); // Retrieve a small amount of Marketplace comments at a time, paging through until all // Marketplace comments have been retrieved. int totalResultSetSize = 0; do { MarketplaceCommentPage page = proposalService.getMarketplaceCommentsByStatement( statementBuilder.ToStatement()); // Print out some information for each Marketplace comment. if (page.results != null) { totalResultSetSize = page.totalResultSetSize; int i = page.startIndex; foreach (MarketplaceComment marketplaceComment in page.results) { String creationTimeString = new System.DateTime( day: marketplaceComment.creationTime.date.day, month: marketplaceComment.creationTime.date.month, year: marketplaceComment.creationTime.date.year, hour: marketplaceComment.creationTime.hour, minute: marketplaceComment.creationTime.minute, second: marketplaceComment.creationTime.second ).ToString("s"); Console.WriteLine( "{0}) Marketplace comment with creation time \"{1}\" " + "and comment \"{2}\" was found.", i++, creationTimeString, marketplaceComment.comment ); } } statementBuilder.IncreaseOffsetBy(pageSize); } while (statementBuilder.GetOffset() < totalResultSetSize); Console.WriteLine("Number of results found: {0}", totalResultSetSize); }
public async Task <ActionMessage> Put(int id, [FromForm] ProposalInfo _proposal, [FromForm] List <IFormFile> files) { ActionMessage ret = new ActionMessage(); ret.isSuccess = true; try { ret = ProposalService.GetInstance().editProposal(id, _proposal, GetUserId()); //update list file //ProposalService.GetInstance().DelteDocument(id.ToString()); if (ret.isSuccess == false) { return(ret); } //++edit item ret = ProposalService.GetInstance().EditItems(id, _proposal.Items); if (ret.isSuccess == false) { return(ret); } //++EDIT document //delete old document DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_proposal.Documents, TableFile.Proposal.ToString(), id); //add new document foreach (var item in files) { DocumentInfo documentInfo = new DocumentInfo(); documentInfo.TableName = TableFile.Proposal.ToString(); documentInfo.PreferId = id.ToString(); documentInfo.FileName = item.FileName; documentInfo.Link = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName); documentInfo.Length = item.Length.ToString(); documentInfo.Type = item.ContentType; ret = await FilesHelpers.UploadFile(TableFile.Proposal.ToString(), _proposal.ProposalID.ToString(), item, documentInfo.Link); DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId()); } //--EDIT document } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }