public async Task <PostFinalizeVM> FinalizeOrder(string id, FinalizeDTO model) { string url = siteSettings.PordoUrl; var client = _clientFactory.CreateClient(); var request = new HttpRequestMessage(HttpMethod.Post, url + $"/orders/{id}/finalize"); StringContent content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); request.Content = content; request.Headers.Add("Authorization", "Bearer " + Token); var response = await client.SendAsync(request); //if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) // return Unauthorized(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(null); } var api = Newtonsoft.Json.JsonConvert.DeserializeObject <PostFinalizeVM>(await response.Content.ReadAsStringAsync()); return(api); }
public async Task <ApiResult <PostFinalizeVM> > FinalizeOrder(string id, FinalizeDTO model, CancellationToken cancellationToken) { var t = await _dispacherService.FinalizeOrder(id, model, cancellationToken); if (t.IsSuccess) { return(Ok(t.Data)); } else { return(BadRequest()); } }
public async Task <ServiceResult <PostFinalizeVM> > FinalizeOrder(string id, FinalizeDTO model, CancellationToken cancellationToken) { //save State var order = _orders.FirstOrDefault(z => z.Order_Id == id); if (!DateTime.TryParse(model.Pickup_date, out var date)) { return(new ServiceResult <PostFinalizeVM>(false, ApiResultStatusCode.BadRequest, null, "تاریخ ارسالی صحیح نمی باشد.")); } order.Pickup_date_Dm = date; order.Option_id = model.Option_id; order.Status = "نهایی"; order.Comment = model.Comment; _orders.Update(order); return(await new PadroService(_configuration, _clientFactory, _env).FinalizeOrder(id, model)); }