public async Task <ApiResult <bool> > Create(CreatePlan bundle) { var json = JsonConvert.SerializeObject(bundle); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"/api/ProcessPlan"; var result = await Create <bool>(url, httpContent); return(result); }
public async Task <IActionResult> Create(CreatePlanViewModel model) { if (ModelState.IsValid) { var createPlan = new CreatePlan { Name = model.Name, RecipeDetail = await dataContext.RecipeDetails.FirstOrDefaultAsync(m => m.Id == model.RecipeDetailId), }; dataContext.CreatePlans.Add(createPlan); await dataContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public Plan Post(CreatePlan request) { //var plan = request.ConvertTo<Plan>(); Plan plan = new Plan(); plan.Name = request.Name; plan.RaceId = request.RaceId; plan.MinSwimWorkouts = request.MinSwimWorkouts; plan.MinBikeWorkouts = request.MinBikeWorkouts; plan.MinRunWorkouts = request.MinRunWorkouts; plan.MaxWorkouts = request.MaxWorkouts; plan.MaxBricks = request.MaxBricks; plan.MinRestDays = request.MinRestDays; Db.Save(plan); return(plan); }
public IActionResult Create([FromBody] CreatePlan model) { var plan = _mapper.Map <Plan>(model); try { // create plan _planService.Create(plan); return(Ok(new { plan.Id, plan.Title, })); } catch (AppException ex) { // return error message if there was an cexception return(BadRequest(new { message = ex.Message })); } }
public ICommandResult Handle(CreatePlanInput input) { var group = _groupRepository.GetById(input.GroupId); var plan = new Plan(input.Name, group, input.ValueCents); plan.SetInterval(input.Interval, input.IntervalType); var validator = new PlanValidator().Validate(plan); if (validator.IsValid) { var body = new CreatePlan(input.Name, plan.Id.ToString(), input.Interval, input.IntervalType, Convert.ToInt32(input.ValueCents * 100), "credit_card"); var result = JsonConvert.DeserializeObject <CreatePlanResult>(Requests.Post("plans", body, Runtime.IuguApiToken)); plan.SetIuguId(result.Id); _planRepository.Create(plan); } return(new CommandResult("Plano criado com sucesso!", validator.Errors)); }
public async Task <ApiResult <bool> > Create(CreatePlan bundle) { var processingDetails = new List <ProcessingDetail>(); if (bundle.Pack.Length > 0) { var i = 0; foreach (var item in bundle.Pack) { processingDetails.Add(new ProcessingDetail() { Amount = bundle.Amount[i], IdRecipe = bundle.IdMaterials[i], Unit = item }); i++; } } // lưu code var user = await _userManager.FindByNameAsync(bundle.NameCreator); var code = await _context.ManageCodes.FirstOrDefaultAsync(x => x.Name == bundle.Code); var stt = 1; Location: var location = code.Location + stt; var str = code.Name + location; var checkCode = await _context.OrderPlans.AnyAsync(x => x.Code == str); if (checkCode) { stt++; goto Location; } code.Location = location; _context.ManageCodes.Update(code); await _context.SaveChangesAsync(); // kế hoạch var process = new ProcessPlan() { Code = str, CreatedDate = DateTime.Now, ExpectedDate = bundle.ExpectedDate, Note = bundle.Note, IdCreator = user.Id, IdResponsible = bundle.IdResponsible, ProcessingDetails = processingDetails, Name = bundle.Name }; _context.ProcessPlans.Add(process); await _context.SaveChangesAsync(); return(new ApiSuccessResult <bool>()); }
public object Post(CreatePlan request) { return(Store.Post <Plan>(request.Data)); }
public async Task <IActionResult> Create([FromBody] CreatePlan bundle) { var result = await _processPlanService.Create(bundle); return(Ok(result)); }
public async Task <IActionResult> Create(CreatePlan bundle) { var result = await _processPlanApiClient.Create(bundle); return(Ok(result)); }