public PlanDTO Get(int id) { var query = _services.GetById(id); PlanDTO dtos = Models.Factory.FactoryPlanDTO.GetInstance().CreateDTO(query); return(dtos); }
public async ThreadTask.Task <bool> UpdateByIdAsync(PlanDTO plan, int id) { var toUpdate = await db.Plans.Get(id); if (toUpdate == null) { return(false); } var modified = false; if (!string.IsNullOrEmpty(plan.Name)) { toUpdate.Name = plan.Name; modified = true; } if (plan.Description != null) { toUpdate.Description = plan.Description; modified = true; } if (plan.Modid != null) { toUpdate.Mod_Id = plan.Modid; modified = true; } toUpdate.Published = plan.Published; db.Plans.UpdateAsync(toUpdate); db.Save(); return(modified); }
//public ChargePlanViewModel ChargePlanViewModel { get; set; } public IndexViewModel() { plan = new PlanDTO(); lesPlans = new List <SelectListItem>(); PlanViewModel = new PlanViewModel(); //ChargePlanViewModel = new ChargePlanViewModel(); }
public bool UpdateById(PlanDTO plan, int id) { var modified = false; var toUpdate = Get(id); if (toUpdate != null) { if (!string.IsNullOrEmpty(plan.Name)) { toUpdate.Name = plan.Name; modified = true; } if (plan.Description != null) { toUpdate.Description = plan.Description; modified = true; } if (plan.Modid != null) { toUpdate.Mod_Id = plan.Modid; modified = true; } toUpdate.Published = plan.Published; Update(toUpdate); } return(modified); }
public bool UpdateById(PlanDTO plan, int id) { var toUpdate = db.Plans.Get(id); if (toUpdate == null) { return(false); } bool modified = false; if (!string.IsNullOrEmpty(plan.Name)) { toUpdate.Name = plan.Name; modified = true; } if (plan.Description != null) { toUpdate.Description = plan.Description; modified = true; } if (plan.Modid != null) { toUpdate.Mod_Id = plan.Modid; modified = true; } modified = !modified && toUpdate.Published != plan.Published; toUpdate.Published = plan.Published; db.Plans.Update(toUpdate); db.Save(); return(modified); }
// Manual mapping method to resolve DO-1164. public static PlanDTO MapPlanToDto(PlanDO curPlanDO) { var subPlanDTOList = curPlanDO.ChildNodes.OfType <SubplanDO>() .OrderBy(x => x.Ordering) .ToList() .Select((SubplanDO x) => { var pntDTO = Mapper.Map <FullSubplanDto>(x); pntDTO.Activities = x.ChildNodes.OrderBy(y => y.Ordering).Select(Mapper.Map <ActivityDTO>).ToList(); return(pntDTO); }).ToList(); var result = new PlanDTO() { Description = curPlanDO.Description, Id = curPlanDO.Id, Name = curPlanDO.Name, PlanState = PlanState.IntToString(curPlanDO.PlanState), Visibility = new PlanVisibilityDTO() { Hidden = curPlanDO.Visibility.BooleanValue() }, StartingSubPlanId = curPlanDO.StartingSubPlanId, SubPlans = subPlanDTOList, Fr8UserId = curPlanDO.Fr8AccountId, Tag = curPlanDO.Tag, Category = curPlanDO.Category, LastUpdated = curPlanDO.LastUpdated }; return(result); }
public async Task <ActivityDTO> AddAndConfigureSaveToFr8Warehouse(PlanDTO plan, int ordering) { var activityName = "Save_To_Fr8_Warehouse"; var saveToFr8WarehouseActivity = FixtureData.Save_To_Fr8_Warehouse_InitialConfiguration(); var activityCategoryParam = ActivityCategories.ProcessId.ToString(); var activityTemplates = await _baseHubITest.HttpGetAsync <List <WebServiceActivitySetDTO> >(_baseHubITest.GetHubApiBaseUrl() + "webservices?id=" + activityCategoryParam); var apmActivityTemplate = activityTemplates .SelectMany(a => a.Activities) .Select(x => new ActivityTemplateSummaryDTO { Name = x.Name, Version = x.Version, TerminalName = x.Terminal.Name, TerminalVersion = x.Terminal.Version }) .Single(a => a.Name == activityName); saveToFr8WarehouseActivity.ActivityTemplate = apmActivityTemplate; //connect current activity with a plan var subPlan = plan.SubPlans.FirstOrDefault(); saveToFr8WarehouseActivity.ParentPlanNodeId = subPlan.SubPlanId; saveToFr8WarehouseActivity.RootPlanNodeId = plan.Id; saveToFr8WarehouseActivity.Ordering = ordering; //call initial configuration to server saveToFr8WarehouseActivity = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/save", saveToFr8WarehouseActivity); //this call is without authtoken saveToFr8WarehouseActivity = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/configure", saveToFr8WarehouseActivity); return(saveToFr8WarehouseActivity); }
private async Task PrepareGetData(PlanDTO plan) { var getDataActivity = plan.SubPlans.First().Activities.Last(); //set lead and do the follow up config using (var crateStorage = Crate.GetUpdatableStorage(getDataActivity)) { crateStorage.UpdateControls <Get_Data_v1.ActivityUi>(x => { x.SalesforceObjectSelector.selectedKey = SalesforceObjectType.Lead.ToString(); }); } getDataActivity = await ConfigureActivity(getDataActivity); Debug.WriteLine("Get Data Follow up config is successfull with Lead selected"); //set the lead required fields. using (var crateStorage = Crate.GetUpdatableStorage(getDataActivity)) { crateStorage.UpdateControls <Get_Data_v1.ActivityUi>(x => { x.SalesforceObjectFilter.Value = JsonConvert.SerializeObject(new List <FilterConditionDTO> { new FilterConditionDTO { Field = "LastName", Operator = "eq", Value = "Unit" } }); }); } getDataActivity = await ConfigureActivity(getDataActivity); Debug.WriteLine("Get Data Follow up config is successfull with selection query fields set."); plan.SubPlans.First().Activities[1] = getDataActivity; }
public static PlanDTO Read(int planId) { PlanDTO planRead = null; try { databaseDataContext db = new databaseDataContext(); var find = (from plan in db.Plans where plan.Id == planId select plan).FirstOrDefault(); planRead = new PlanDTO() { Id = find.Id, UserId = find.UserId, Name = find.Name }; } catch (Exception e) { Console.WriteLine(e.Message); } return(planRead); }
public IActionResult CreatePlan(PlanDTO plan) { _loggerManager.Info($"CreatePlan is requested"); Response.StatusCode = StatusCodes.Status202Accepted; if (ModelState.IsValid) { var result = _planRepository.CreatePlan(plan, HttpContext.GetUserId()); if (result) { _loggerManager.Info($"CreatePlan successfully created a plan"); Response.StatusCode = StatusCodes.Status201Created; } else { _loggerManager.Warn($"CreatePlan was unable to create a plan"); ModelState.AddModelError(string.Empty, sharedResource.worksheetCreatePlanProblem); } } else { _loggerManager.Info($"CreatePlan request is invalid"); } return(PartialView("~/Views/Worksheet/Partials/_NewPlan.cshtml")); }
private async Task <PlanDTO> CreateMonitoringPlan(Guid authTokenId) { PlanDTO plan = null; try { plan = await _plansHelper.CreateNewPlan(); var activityTemplate = await ExtractActivityTemplate(); var activity = await AddActivityToPlan(authTokenId, plan, activityTemplate); await ConfigureMonitorActivity(activity); return(plan); } catch { if (plan != null) { await HttpDeleteAsync(GetHubApiBaseUrl() + "/plans?id=" + plan.Id.ToString()); } throw; } }
public HttpResponseMessage PostAndReturnId([FromBody] PlanDTO value) { try { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var result = planService.AddAndGetId(value); if (result != null) { var log = $"Succesfully created plan {value.Name} with id = {result} by user with id = {value.CreatorId}"; tracer.Info(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, log); return(Request.CreateResponse(HttpStatusCode.OK, result)); } } catch (EntityException e) { tracer.Error(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } tracer.Warn(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, "Error occured on creating plan"); const string message = "Incorrect request syntax."; return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, message)); }
public static List <PlanDTO> ReadAll() { List <PlanDTO> plans = new List <PlanDTO>();; try { databaseDataContext db = new databaseDataContext(); var find = (from plan in db.Plans select plan); foreach (Plan plan in find) { PlanDTO planRead = new PlanDTO() { Id = plan.Id, UserId = plan.UserId, Name = plan.Name }; plans.Add(planRead); } } catch (Exception ex) { Console.WriteLine(ex); } return(plans); }
private async Task PrepareSaveToLead(PlanDTO plan) { var saveActivity = plan.SubPlans.First().Activities.First(); //set lead and do the follow up config using (var updatableStorage = Crate.GetUpdatableStorage(saveActivity)) { var ddlb = (DropDownList)updatableStorage.CratesOfType <StandardConfigurationControlsCM>().Single().Content.Controls[0]; ddlb.selectedKey = "Lead"; } saveActivity = await ConfigureActivity(saveActivity); Debug.WriteLine("Save to Salesforce Follow up config is successfull with Lead selected."); //set the lead required fields. using (var updatableStorage = Crate.GetUpdatableStorage(saveActivity)) { var requiredControls = updatableStorage.CratesOfType <StandardConfigurationControlsCM>().Single().Content.Controls; var lastNameControl = (TextSource)requiredControls.Single(c => c.Name.Equals("LastName")); lastNameControl.ValueSource = "specific"; lastNameControl.TextValue = "Unit"; var companyControl = (TextSource)requiredControls.Single(c => c.Name.Equals("Company")); companyControl.ValueSource = "specific"; companyControl.TextValue = "Test"; } saveActivity = await ConfigureActivity(saveActivity); Debug.WriteLine("Save to Salesforce Follow up config is successfull with required fields set."); plan.SubPlans.First().Activities[0] = saveActivity; }
public frmplansingle(PlanDTO dto, string OP) { InitializeComponent(); dtoaction = dto; Operation = OP; if (OP == "A") { this.Text = "Agregar Plan"; button1.Text = "Agregar"; button2.Text = "Cancelar"; FillComboESpecialidad(); } else if (OP == "M") { this.Text = "Actualizar Plan"; txtIdplan.ReadOnly = true; button1.Text = "Modificar"; button2.Text = "Cancelar"; FillComboESpecialidad(dto.id_especialidad); txtIdplan.Text = dto.id_plan.ToString(); txtdescplan.Text = dto.desc_plan; } else if (OP == "D") { txtIdplan.ReadOnly = true; txtdescplan.ReadOnly = true; button1.Text = "Eliminar"; button2.Text = "Cancelar"; txtIdplan.Text = dto.id_plan.ToString(); txtdescplan.Text = dto.desc_plan; FillComboESpecialidad(); } }
/// <summary> /// Add new Get_Google_Sheet_Data activity to an existing plan and configure that activity with selected spreadsheet /// </summary> /// <param name="plan">Existing plan that will be associated with new Get_Google_Sheet_Data activity</param> /// <param name="ordering">Ordering of Get_Google_Sheet_Data activity into plan </param> /// <param name="spreadsheetName">name of the spreadsheet use in configure procees</param> /// <param name="includeFixtureAuthToken">Use fixture data as google auth token</param> /// <returns>Configured ActivityDTO for Get_Google_Sheet_Data</returns> public async Task <ActivityDTO> AddAndConfigureGetFromGoogleSheet(PlanDTO plan, int ordering, string spreadsheetName, bool includeFixtureAuthToken) { var activityName = "Get_Google_Sheet_Data"; var getFromGoogleSheetActivityDTO = await AddGoogleActivityToPlan(FixtureData.Get_Google_Sheet_Data_v1_InitialConfiguration(), plan, ordering, ActivityCategories.ReceiveId, activityName); return(await ConfigureGetFromGoogleSheetActivity(getFromGoogleSheetActivityDTO, spreadsheetName, includeFixtureAuthToken)); }
protected async Task <ContainerDTO> ExecutePlan(PlanDTO plan) { var container = await HttpPostAsync <string, ContainerDTO>( _baseUrl + "plans/run?planId=" + plan.Id, null ); return(container); }
private void btnmodificar_Click(object sender, EventArgs e) { Int32 id = Convert.ToInt32(DGVGrilla[0, DGVGrilla.CurrentRow.Index].Value); PlanDTO getplan = Myproxy().Get(id, ""); frmplansingle frm = new frmplansingle(getplan, "M"); frm.ShowDialog(); LoadForm(); }
private ActivityDTO ExtractSolution(PlanDTO plan) { var solution = plan.SubPlans .FirstOrDefault() .Activities .FirstOrDefault(); return(solution); }
public static PlanDTO PlanToDTO(Plan Plan) { if (Plan == null) { return(null); } Mapper.CreateMap <Plan, PlanDTO>(); PlanDTO PlanDTO = Mapper.Map <PlanDTO>(Plan); return(PlanDTO); }
public void UpdatePlanTest_ShouldReturnBadRequestMessage() { planServiceMock.Setup(u => u.UpdateById(It.IsAny <PlanDTO>(), It.IsAny <int>())).Returns(false); PlanDTO forUpdating = new PlanDTO(1, "name1", "description1", true, 1, "nameCreator1", "lastenameCreator1", 1, "nameCreator1", "lastenameCreator1", DateTime.Now, DateTime.Now); var response = planController.Put(1, forUpdating); var expectedStatusCode = HttpStatusCode.BadRequest; var actualStatusCode = response.StatusCode; Assert.AreEqual(expectedStatusCode, actualStatusCode); }
private void btneliminar_Click(object sender, EventArgs e) { if (MessageBox.Show("Estas seguro de eliminar este registro ?", "Eliminar registro", MessageBoxButtons.YesNo) == DialogResult.Yes) { Int32 id = Convert.ToInt32(DGVGrilla[0, DGVGrilla.CurrentRow.Index].Value); PlanDTO getplan = Myproxy().Get(id, ""); frmplansingle frm = new frmplansingle(getplan, "D"); frm.ShowDialog(); LoadForm(); } }
public static Plan PlanToDomain(PlanDTO PlanDTO) { if (PlanDTO == null) { return(null); } Mapper.CreateMap <PlanDTO, Plan>(); Plan Plan = Mapper.Map <Plan>(PlanDTO); return(Plan); }
public void UpdatePlanTest_ShouldCatchEntityExeption() { planServiceMock.Setup(u => u.UpdateById(It.IsAny <PlanDTO>(), It.IsAny <int>())) .Throws(new EntityException()); PlanDTO forUpdating = new PlanDTO(1, "name1", "description1", true, 1, "nameCreator1", "lastenameCreator1", 1, "nameCreator1", "lastenameCreator1", DateTime.Now, DateTime.Now); var response = planController.Put(1, forUpdating); var expectedStatusCode = HttpStatusCode.InternalServerError; var actualStatusCode = response.StatusCode; Assert.AreEqual(expectedStatusCode, actualStatusCode); }
public static PlanDTO ToDTO(Plan entity) { var dto = new PlanDTO(); dto.CardTransactions = entity.CardTransactions; dto.Cost = entity.Cost; dto.Currency = entity.Currency; dto.Insurance = entity.Insurance; dto.MaxExchange = entity.MaxExchange; dto.Type = entity.Type; return(dto); }
public static Plan ToEntity(PlanDTO dto) { var entity = new Plan(); entity.CardTransactions = dto.CardTransactions; entity.Cost = dto.Cost; entity.Currency = dto.Currency; entity.Insurance = dto.Insurance; entity.MaxExchange = dto.MaxExchange; entity.Type = dto.Type; return(entity); }
/// <summary> /// Add Build_Message activity to existing plan and configure the activity with message name and body template /// </summary> /// <param name="plan"></param> /// <param name="ordering"></param> /// <param name="messageName"></param> /// <param name="messageBodyTemplate"></param> /// <returns></returns> public async Task <ActivityDTO> AddAndConfigureBuildMessage(PlanDTO plan, int ordering, string messageName, string messageBodyTemplate) { var activityName = "Build_Message"; var buildMessageActivityDTO = FixtureData.Build_Message_v1_InitialConfiguration(); var activityCategoryParam = ActivityCategories.ProcessId.ToString(); var activityTemplates = await _baseHubITest.HttpGetAsync <List <WebServiceActivitySetDTO> >(_baseHubITest.GetHubApiBaseUrl() + "webservices?id=" + activityCategoryParam); var apmActivityTemplate = activityTemplates .SelectMany(a => a.Activities) .Select(x => new ActivityTemplateSummaryDTO { Name = x.Name, Version = x.Version, TerminalName = x.Terminal.Name, TerminalVersion = x.Terminal.Version }) .Single(a => a.Name == activityName); buildMessageActivityDTO.ActivityTemplate = apmActivityTemplate; //connect current activity with a plan var subPlan = plan.SubPlans.FirstOrDefault(); buildMessageActivityDTO.ParentPlanNodeId = subPlan.SubPlanId; buildMessageActivityDTO.RootPlanNodeId = plan.Id; buildMessageActivityDTO.Ordering = ordering; //call initial configuration to server buildMessageActivityDTO = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/save", buildMessageActivityDTO); //this call is without authtoken buildMessageActivityDTO = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/configure", buildMessageActivityDTO); //call followup configuration using (var crateStorage = _baseHubITest.Crate.GetUpdatableStorage(buildMessageActivityDTO)) { var controlsCrate = crateStorage.CratesOfType <StandardConfigurationControlsCM>().First(); Assert.IsNotNull(controlsCrate, $"{activityName}: Crate StandardConfigurationControlsCM is missing in API response"); var activityUi = new Build_Message_v1.ActivityUi(); activityUi.SyncWith(controlsCrate.Content); crateStorage.Remove <StandardConfigurationControlsCM>(); activityUi.Name.Value = messageName; activityUi.Body.Value = messageBodyTemplate; crateStorage.Add(Crate <StandardConfigurationControlsCM> .FromContent(controlsCrate.Label, new StandardConfigurationControlsCM(activityUi.Controls.ToArray()))); } buildMessageActivityDTO = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/save", buildMessageActivityDTO); buildMessageActivityDTO = await _baseHubITest.HttpPostAsync <ActivityDTO, ActivityDTO>(_baseHubITest.GetHubApiBaseUrl() + "activities/configure", buildMessageActivityDTO); return(buildMessageActivityDTO); }
public PlanDTO CreateDTO(PlanBE be) { PlanDTO dto = new PlanDTO() { id_plan = be.id_plan, desc_plan = be.desc_plan, id_especialidad = be.id_especialidad, Especialidad = be.especialidades != null?FactoryEspecialidadDTO.GetInstance().CreateDTO(be.especialidades) : null, estado = be.estado }; return(dto); }
public IActionResult Update([FromBody] PlanDTO planDto) { try { //var claimCompanyId = _httpContextAccessor.HttpContext.User.FindFirst("CompanyId"); //planDto.CompanyId = (claimCompanyId == null) ? 0 : Int32.Parse(claimCompanyId.Value); _planManager.Update(planDto); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <PlanFullDTO> UpdatePlanCategory(Guid activityId, string category) { PlanDTO plan = await GetPlansByActivity(activityId.ToString()); if (plan != null && plan.Plan != null) { plan.Plan.Category = category; var emptyPlanDTO = Mapper.Map <PlanEmptyDTO>(plan.Plan); plan = await UpdatePlan(emptyPlanDTO); } return(plan.Plan); }
public static PlanDTO CreatePlanDTO(global::System.Guid ID, bool isValid, int versionNumber, global::System.DateTime createDate, bool isFinished, int status, int publishStatus, int year, global::System.Guid airlinesId, global::System.Guid annualId) { PlanDTO planDTO = new PlanDTO(); planDTO.Id = ID; planDTO.IsValid = isValid; planDTO.VersionNumber = versionNumber; planDTO.CreateDate = createDate; planDTO.IsFinished = isFinished; planDTO.Status = status; planDTO.PublishStatus = publishStatus; planDTO.Year = year; planDTO.AirlinesId = airlinesId; planDTO.AnnualId = annualId; return planDTO; }
public void AddToPlans(PlanDTO planDTO) { base.AddObject("Plans", planDTO); }