public ShipperViewModel Add(ShipperViewModel viewModel) { var model = Mapper.Map <ShipperViewModel, Shipper>(viewModel); _shipperRepository.Add(model); return(viewModel); }
public ActionResult ShipperMain(ShipperCondition condition) { ShipperAction action = new ShipperAction(); ShipperViewModel viewModel = action.SearchGridView(condition); return(View(viewModel)); }
public void CreateShipper(ShipperViewModel shipper) { var shipperInsert = Mapper.Map <ShipperViewModel, Shipper_M>(shipper); _shipperRepository.Add(shipperInsert); SaveShipper(); }
public IHttpActionResult GetById(int id = 0) { try { var ship = db.Shippers.Find(id); if (ship == null) { return(NotFound()); } var data = new ShipperViewModel() { ShipperID = ship.ShipperID, CompanyName = ship.CompanyName, Phone = ship.Phone }; return(Ok(new { success = true, data = data })); } catch (Exception ex) { return(BadRequest($"Bir hata oluştur {ex.Message}")); } }
/// <summary> /// /// </summary> /// <param name="viewModel"></param> /// <returns></returns> public static Shipper ToEntity(this ShipperViewModel viewModel) { return(viewModel == null ? null : new Shipper { Id = viewModel.Id, Company = viewModel.Company, //TransactionId = entity.TransactionId, Last_Name = viewModel.Last_Name, First_Name = viewModel.First_Name, Email_Address = viewModel.Email_Address, Job_Title = viewModel.Job_Title, Business_Phone = viewModel.Business_Phone, Home_Phone = viewModel.Home_Phone, Mobile_Phone = viewModel.Mobile_Phone, Fax_Number = viewModel.Fax_Number, Address = viewModel.Address, City = viewModel.City, State_Province = viewModel.State_Province, Zip_Postal_Code = viewModel.Zip_Postal_Code, Country_Region = viewModel.Country_Region, Web_Page = viewModel.Web_Page, Notes = viewModel.Notes, Attachments = viewModel.Attachments // //RowGuid = viewModel.RowGuid, //ModifiedDate = viewModel.ModifiedDate }); }
public async Task <ActionResult> Shipper(string keyword, int?pageIndex) { return(await Task.Run <ActionResult>(() => { var getCRMShippersByConditionRequest = new GetShippersByConditionRequest(); getCRMShippersByConditionRequest.SearchCondition = new ShipperSearchCondition() { KeyWord = keyword }; getCRMShippersByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE; getCRMShippersByConditionRequest.PageIndex = pageIndex ?? 0; ShipperViewModel vm = new ShipperViewModel(); var getCRMShippersByConditionResponse = new ShipperManagementService().GetShippersByCondition(getCRMShippersByConditionRequest); if (getCRMShippersByConditionResponse.IsSuccess) { vm.CRMShipperCollection = getCRMShippersByConditionResponse.Result.ShipperCollection; vm.PageIndex = getCRMShippersByConditionResponse.Result.PageIndex; vm.PageCount = getCRMShippersByConditionResponse.Result.PageCount; } else { throw new Exception(getCRMShippersByConditionResponse.Exception.Message); } return Json(vm, JsonRequestBehavior.AllowGet); })); }
public void UpdateShipper(ShipperViewModel shipper) { var shipperToRemove = _shipperRepository.GetById(shipper.ShipperC); var updateShipper = Mapper.Map <ShipperViewModel, Shipper_M>(shipper); _shipperRepository.Delete(shipperToRemove); _shipperRepository.Add(updateShipper); SaveShipper(); }
public IActionResult AddShipper([FromBody] ShipperViewModel shipperView) { var res = shipperOperations.AddShipper(shipperView); if (!ModelState.IsValid) { return(BadRequest()); } return(Created("", res)); }
public IActionResult Update([FromBody] ShipperViewModel shipperView) { var res = shipperOperations.UpdateShipper(shipperView); if (res == null) { return(BadRequest()); } return(Ok(res)); }
public async Task <IActionResult> CreateShipperAsync([FromBody] ShipperViewModel value) { var response = new SingleModelResponse <ShipperViewModel>() as ISingleModelResponse <ShipperViewModel>; try { var entity = await Task.Run(() => { return(_RESTfulAPI_Repository.AddShipper(value.ToEntity())); }); if (response.DidError == false) { response.Model = entity.ToViewModel(); } } catch (Exception ex) { string webRoot = _hostingEnvironment.WebRootPath; string errorGuid = String.Format(Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 16)); HttpContext.Session.SetString("ErrorGuid", errorGuid); ViewBag.ErrorGuid = HttpContext.Session.GetString("ErrorGuid"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { using (StreamWriter w = new StreamWriter(webRoot + "\\log.txt", append: true)) { Log.Logging(ex.ToString(), w, ViewBag.ErrorGuid); } } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { using (StreamWriter w = new StreamWriter(webRoot + "/log.txt", append: true)) { Log.Logging(ex.ToString(), w, ViewBag.ErrorGuid); } } response.DidError = true; //response.ErrorMessage = ex.ToString(); return(this.Json(new { timestamp = DateTime.Now, errorGuid = ViewBag.ErrorGuid, status = HttpStatusCode.InternalServerError, info = "Error logged in log file." })); } response.Info = "Client " + " " + HttpContext.Connection.RemoteIpAddress.ToString(); return(response.ToHttpResponse()); }
public Shipper AddShipper(ShipperViewModel shipperView) { Shipper shipper = new Shipper { CompanyName = shipperView.CompanyName, Phone = shipperView.Phone, ShipperId = shipperView.ShipperId }; shipperRepository.Add(shipper); shipperRepository.SaveChanges(); return(shipper); }
public async Task Must_Not_Add_Valid_Shipper() { await AuthanticateAccountAsync(); var shipperViewModel = new ShipperViewModel() { CompanyName = string.Empty, Phone = "(503) 555 - 9831" }; var httpResponseMessage = _httpTestClient.PostAsJsonAsync("/api/shipper/add", shipperViewModel).Result; httpResponseMessage.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public async Task Must_Not_Update_Valid_Shipper() { await AuthanticateAccountAsync(); var shipper = await CreateShipper(); var shipperViewModel = new ShipperViewModel() { Id = shipper.Id, CompanyName = string.Empty, Phone = shipper.Phone, }; var httpResponseMessage = _httpTestClient.PutAsJsonAsync("/api/shipper/update", shipperViewModel).Result; httpResponseMessage.StatusCode.Should().Be(HttpStatusCode.BadRequest); }
public JsonResult Save(ShipperViewModel info) { //insert return(Json(APIHelper.CallAPI <JsonResultData>("shipper/insert", new MD_SHIPPER { NOTE = info.SHIPPERNOTE, TELEPHONE = info.SHIPPERTEL, ADDRESS = info.SHIPPERADDR, FAX = info.SHIPPERFAX, SHIPPERNAME = info.SHIPPERNAME, SHIPPERPRIMARY = info.SHIPPERPRIMARY, CREATEDUSER = LoginUser.Current.USERNAME, CREATEDDATE = DateTime.Now }), JsonRequestBehavior.AllowGet)); }
public ActionResult Add(ShipperViewModel shipper) { try { Shipper s = new Shipper(); s.CompanyName = shipper.CompanyName; s.Phone = shipper.Phone; db.Shippers.Add(s); db.SaveChanges(); return(Json("ok", JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public ActionResult Select(int id) { ShipperViewModel shipper = db.Shippers.Where(a => a.ShipperID == id).Select(a => new ShipperViewModel { ShipperID = a.ShipperID, CompanyName = a.CompanyName, Phone = a.Phone }).SingleOrDefault(); if (shipper != null) { //TempData["ID"] = shipper.ShipperID; shipperID = shipper.ShipperID; return(Json(shipper, JsonRequestBehavior.AllowGet)); } else { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public Shipper Add(ShipperViewModel model) { logger.LogInformation("ShipperOperation --- Add method started"); Shipper shipper = new Shipper { ShipperId = model.ShipperId, CompanyName = model.CompanyName, Phone = model.Phone }; repository.Shippers.Add(shipper); repository.SaveChanges(); logger.LogInformation("ShipperOperation --- Add method finished"); return(shipper); }
public Shipper UpdateShipper(ShipperViewModel shipperView) { Shipper shipper = new Shipper { ShipperId = shipperView.ShipperId }; if (shipperView.CompanyName != null) { shipper.CompanyName = shipperView.CompanyName; } if (shipperView.Phone != null) { shipper.Phone = shipperView.Phone; } shipperRepository.Update(shipper); shipperRepository.SaveChanges(); return(shipper); }
public Shipper Edit(ShipperViewModel model) { logger.LogInformation("ShipperOperation --- Edit method started"); Shipper shipper = new Shipper { ShipperId = model.ShipperId }; shipper.Phone = model.Phone; shipper.CompanyName = model.CompanyName; repository.Shippers.Update(shipper); repository.SaveChanges(); logger.LogInformation("ShipperOperation --- Edit method finished"); return(shipper); }
public IHttpActionResult Add([FromBody] ShipperViewModel model) { try { db.Shippers.Add(new Shipper() { CompanyName = model.CompanyName, Phone = model.Phone }); db.SaveChanges(); return(Ok(new { success = true, message = "Shipper eklendi" })); } catch (Exception ex) { return(BadRequest($"Bir hata oluştu {ex.Message}")); } }
public async Task <ActionResult> Shipper() { return(await Task.Run <ActionResult>(() => { ShipperViewModel vm = new ShipperViewModel(); var getCRMShippersByConditionRequest = new GetShippersByConditionRequest(); getCRMShippersByConditionRequest.SearchCondition = new ShipperSearchCondition(); getCRMShippersByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE; getCRMShippersByConditionRequest.PageIndex = 0; var getCRMShippersByConditionResponse = new ShipperManagementService().GetShippersByCondition(getCRMShippersByConditionRequest); if (getCRMShippersByConditionResponse.IsSuccess) { vm.CRMShipperCollection = getCRMShippersByConditionResponse.Result.ShipperCollection; vm.PageIndex = getCRMShippersByConditionResponse.Result.PageIndex; vm.PageCount = getCRMShippersByConditionResponse.Result.PageCount; } return View(vm); })); }
public IActionResult SaveEntity(ShipperViewModel viewModel) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(n => n.Errors); return(new BadRequestObjectResult(allErrors)); } else { if (viewModel.Id == 0) { _shipperService.Add(viewModel); } else { _shipperService.Update(viewModel); } } _shipperService.Save(); return(new OkObjectResult(viewModel)); }
public IHttpActionResult Put(int id, ShipperViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != model.ShipperID) { return(BadRequest()); } db.Entry(model).State = EntityState.Modified; try { db.SaveChanges(); return(Ok(new { success = true, message = "Güncelleme işlemi başarılı" })); } catch (DbUpdateConcurrencyException ex) { if (!db.Categories.Any(x => x.CategoryID == id)) { return(NotFound()); } else { return(BadRequest($"Bir hata oluştu {ex.Message}")); } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> UpdateShipperAsync(Int32 id, [FromBody] ShipperViewModel value) { var response = new SingleModelResponse <ShipperViewModel>() as ISingleModelResponse <ShipperViewModel>; try { var entity = await Task.Run(() => { return(_RESTfulAPI_Repository.UpdateShipper(id, value.ToEntity())); }); response.Model = entity.ToViewModel(); response.Info = "The record was updated successfully"; } catch (Exception ex) { response.DidError = true; response.ErrorMessage = ex.Message; } return(response.ToHttpResponse()); }
public IActionResult Edit([FromBody] ShipperViewModel model) { var result = shipper.Edit(model); return(Ok(result)); }
public async Task <IActionResult> Update([FromBody] ShipperViewModel ShipperViewModel) { var data = await _shipperAppService.UpdateShipper(ShipperViewModel); return(Ok(data)); }
public IActionResult Add([FromBody] ShipperViewModel model) { var result = shipper.Add(model); return(Created("", result)); }
public void Put(ShipperViewModel shipper) { _shipperService.UpdateShipper(shipper); }
public void Post(ShipperViewModel shipper) { _shipperService.CreateShipper(shipper); }
public void Update(ShipperViewModel viewModel) { var model = Mapper.Map <ShipperViewModel, Shipper>(viewModel); _shipperRepository.Update(model); }