public void Delete(TruckModel truckModel) { try { if (ValidateDelete(truckModel)) { return; } Common.DAL.Truck truck = dbContext.Trucks.Where(x => x.Id == truckModel.Id).FirstOrDefault(); if (truck == null) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound); return; } dbContext.Trucks.Remove(truck); base.SaveChanges(); truckModel.AddSuccess(Resources.TruckDeletedSuccessfully, LookUps.SuccessType.Full); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Business, null, Resources.RefrenceDeleteError); base.UndoUpdates(); } catch (Exception ex) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Exception, ex); base.UndoUpdates(); } }
public async Task <ActionResult <TruckModel> > PostTruckModel(TruckModel truckModel) { _context.trucks.Add(truckModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTruckModel", new { id = truckModel.Id }, truckModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Description")] TruckModel truckModel) { if (id != truckModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(truckModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TruckModelExists(truckModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(truckModel)); }
public void Get_all_future_hops_should_return_HopArrivalModel_list() { // Arrange HopArrivalModel latest = new HopArrivalModel() { }; TruckModel closestTruck = new TruckModel() { }; RecipientModel recipient = new RecipientModel { FirstName = "Rudi", LastName = "Recipient", Street = "Poststraße", PostalCode = "A-1070", City = "Poststadt" }; ParcelModel parcel = new ParcelModel { Recipient = recipient, Weight = 1.0f }; // Act var result = warehouse.GetAllFutureHops(latest, closestTruck, parcel); // Assert Assert.IsInstanceOfType(result, typeof(IList <HopArrivalModel>)); }
public TruckModelSaveUpdateViewModel SearchTruckModel(TruckModelSaveUpdateViewModel model) { var modelSearchResult = new TruckModel(); if (!string.IsNullOrEmpty(model.Description)) { //Search for model in DB only if numbers and letters in model name if (!_validate.Alphanumeric(model.Description)) { model.IsValid = false; } else { modelSearchResult = _truckModelContext.Collection().Where(m => m.ModelDescription == model.Description).FirstOrDefault(); if (modelSearchResult == null) { model.ExistInDB = false; } else { model.Id = modelSearchResult.Id; model.Description = modelSearchResult.ModelDescription; model.ManufacturerId = modelSearchResult.TruckManufacturerId; var manufacturer = _truckManufacturerContext.Collection().Where(m => m.Id == modelSearchResult.TruckManufacturerId).FirstOrDefault(); model.ManufacturerDescription = manufacturer.ManufacturerDescription; } } } return(model); }
public List <TruckModel> GetTruckList(int pageIndex, int pageSize, string number, DateTime dateTime, out int total) { total = 0; QueryPageModel queryPageModel = new QueryPageModel(); queryPageModel.OrderBy = "TruckID"; queryPageModel.PageIndex = pageIndex; queryPageModel.PageSize = pageSize; queryPageModel.QuerySql = @"(select * from [Truck]) u where 1=1 {0} )"; string sqlWhere = ""; TruckModel model = new TruckModel(); if (!string.IsNullOrEmpty(number)) { sqlWhere += " and Number like @Number"; model.Number = number + "%"; } if (dateTime > new DateTime(1950, 1, 1)) { sqlWhere += " and CheckInTime < @CheckInTime"; model.CheckInTime = dateTime; } queryPageModel.QuerySql = string.Format(queryPageModel.QuerySql, sqlWhere); var result = PageDataHelper.QueryWithPage <TruckModel>(queryPageModel, model); total = PageDataHelper.QueryTotalCount(queryPageModel, model); return(result.ToList()); }
public void Edit(TruckModel truckModel) { try { Common.DAL.Truck truck = dbContext.Trucks.Where(x => x.Id == truckModel.Id).FirstOrDefault(); if (truck == null) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound); return; } if (Validate(truckModel)) { return; } TruckMapper.Map(dbContext, truckModel, truck); base.SaveChanges(); truckModel.AddSuccess(Resources.TruckUpdatedSuccessfully, LookUps.SuccessType.Full); } catch (Exception ex) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Exception, ex); base.UndoUpdates(); } }
protected async void GetPendingList() { records.Clear(); string url = ""; if (Title.Equals("Cargo Receiving")) { url = ControllerUtil.getPendingReceivingURL(); } else if (Title.Equals("Cargo Loading")) { url = ControllerUtil.getPendingLoadURL(); } else if (Title.Equals("Cargo Measuring")) { url = ControllerUtil.getPendingReceivingURL(); } var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, url, this); clsResponse pending_response = JsonConvert.DeserializeObject <clsResponse>(content); if (pending_response.IsGood) { App.Database.DeleteTruckModel(); List <clsTruckingModel> trucks = JObject.Parse(content)["Result"].ToObject <List <clsTruckingModel> >(); foreach (clsTruckingModel truck in trucks) { string summary = ""; TruckModel record = new TruckModel(); record.TruckId = truck.TruckId; record.RecordId = truck.Id; foreach (clsCaptionValue truckValue in truck.Summary) { summary += truckValue.Caption + " : " + truckValue.Value + "\r\n" + "\r\n"; if (truckValue.Caption.Equals("Job No.")) { record.JobNo = truckValue.Value; } } record.Summary = summary; //App.Database.SaveTruckModelAsync(record); records.Add(record); } loadPendingList(); } else { await DisplayAlert("JsonError", pending_response.Message, "OK"); } }
// GET: Localizacao public ActionResult Index() { TruckModel model = new TruckModel(); Pessoa pessoa = Session["truck"] as Pessoa; Truck truck = model.Read(pessoa.IdPessoa); return(View(truck)); }
public TruckModel Delete(int id) { TruckModel tm = db.TruckModels.FirstOrDefault(x => x.Id == id); db.TruckModels.Remove(tm); db.SaveChanges(); return(tm); }
public TruckModel Update(TruckModel entity) { TruckModel UpdateEntity = db.TruckModels.FirstOrDefault(x => x.Id == entity.Id); UpdateEntity.ModelCode = entity.ModelCode; db.SaveChanges(); return(UpdateEntity); }
private bool Validate(TruckModel truckModel) { if (dbContext.Trucks.Any(x => x.Name == truckModel.Name && x.Id != truckModel.Id.ToString())) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, truckModel.GetDisplayName(x => x.Name)), truckModel.nameof(x => x.Name)); } return(truckModel.HasErrorByType()); }
public async Task CreateTruck([FromBody] TruckModel model) { await _truckService.CreateTruck(new Trucks { Height = model.Height, Width = model.Width, Number = model.Number }); }
public void PrepareTruckModel(TruckModel truckModel) { try { } catch (Exception ex) { base.HandleError(truckModel, CommonLayer.LookUps.ErrorType.Critical, ex); } }
public IActionResult Index() { TruckModel tm = new TruckModel(); Truck t = new Truck(); t = _translator.Translate <Truck>(tm); tm = _translator.Translate <TruckModel>(t); ViewData["TruckTypes"] = _trucksContext.GetAllTruckTypes(); ViewData["TruckSizes"] = _trucksContext.GetAllTruckSizes(); return(View()); }
public TruckLoadModel() { TruckModel = new TruckModel(false); DriverModel = new DriverModel(false); CompanyModel = new CompanyModel(false); StatusModel = new StatusModel(false); FromStateModel = new USAStateModel(false); ToStateModel = new USAStateModel(false); StatesList = new List <SelectListItem>(); StatusesList = new List <SelectListItem>(); }
public IActionResult Edit(int id) { TruckModel tm = db.GetSingle(id); TruckModelViewModel tmvm = new TruckModelViewModel { Value = tm.Id.ToString(), Text = tm.ModelCode }; return(View(tmvm)); }
public void PostNewTruckModelToDB(TruckModelSaveUpdateViewModel truckModel) { var truckModelToInsert = new TruckModel(); truckModelToInsert.ModelDescription = truckModel.Description; truckModelToInsert.TruckManufacturerId = truckModel.ManufacturerId; _truckModelContext.Insert(truckModelToInsert); _truckModelContext.Commit(); _logger.Info("Inserted record Id " + truckModelToInsert.Id + " into Table " + tableNameUsedByLogger); }
public async Task <IActionResult> Create([Bind("Id,Description")] TruckModel truckModel) { if (ModelState.IsValid) { _context.Add(truckModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(truckModel)); }
public static List <TruckModel> update(TruckModel truck) { var response = new RequestAPI() .addClient(new RestClient(urlRequest)) .addRequest(new RestRequest("truck/update/", Method.GET, DataFormat.Json)) .addHeader(new KeyValuePair <string, object>("Accept", "application/json")) .addBodyData(truck) .buildRequest(); return(RequestAPI.deserilizeProject <List <TruckModel> >(response)); }
public int SaveTruckModelAsync(TruckModel record) { record.owner = Ultis.Settings.SessionUserId; if (record.tableID != 0) { return(database.Update(record)); } else { return(database.Insert(record)); } }
public ActionResult Index(FormCollection form) { Truck truck = new Truck(); truck.NomeTruck = form["nomeTruck"]; if (truck.NomeTruck == "") { Cliente cliente = new Cliente(); cliente.Nome = form["name"]; cliente.Telefone = form["phone"]; cliente.Celular = form["cel"]; cliente.Email = form["email"]; cliente.Senha = form["senha"]; cliente.TipoPessoa = 1; cliente.Status = 1; cliente.CPFCNPJ = form["cpf"]; using (ClienteModel model = new ClienteModel()) { model.Create(cliente); } return(Redirect("Home")); } else { truck.Nome = form["name"]; truck.Telefone = form["phone"]; truck.Celular = form["cel"]; truck.Email = form["email"]; truck.Senha = form["senha"]; truck.TipoPessoa = 0; truck.Status = 1; truck.CNPJ = form["cnpj"]; truck.DescricaoTruck = form["descricao"]; truck.CEP = form["cep"]; truck.Estado = form["uf"]; truck.Cidade = form["cidade"]; truck.Bairro = form["bairro"]; truck.Endereco = form["endereco"]; truck.Numero = form["numero"]; truck.Referencia = form["referencia"]; truck.Latitude = "1"; truck.Longitude = "1"; truck.Logo = 123; using (TruckModel model = new TruckModel()) { model.Create(truck); } return(Redirect("Login")); } }
public void CreateTruckModelViewModel(CreateTruckModelViewModel truckModel) { TruckModel tr = new TruckModel(truckModel.ModelYear, truckModel.Color, truckModel.Engine, truckModel.Potence, truckModel.ResponsableId, truckModel.Status); _contextDb.Add(tr); _contextDb.SaveChanges(); }
public ActionResult Create(BaseModel baseModel) { TruckModel truckModel = new TruckModel(); truckModel.CopyBaseModel(baseModel); using (TruckBAL truckBAL = new TruckBAL(ContextInfo)) { truckBAL.PrepareTruckModel(truckModel); } return(View("Create", truckModel)); }
public ActionResult ViewTruck(string id) { TruckModel truckModel = new TruckModel(); truckModel.Id = id; using (TruckBAL truckBAL = new TruckBAL(ContextInfo)) { truckBAL.GetTruckModel(truckModel); } return(View(truckModel)); }
public static void Map(LMYFrameWorkMVCEntities dbContext, List <Truck> src, List <TruckModel> dest) { if (src == null || dest == null) { return; } foreach (Truck truck in src) { TruckModel truckModel = new TruckModel(); Map(dbContext, truck, truckModel); dest.Add(truckModel); } }
public static void Map(LMYFrameWorkMVCEntities dbContext, TruckModel src, Truck dest) { if (src == null || dest == null) { return; } dest.CopyPropertyValues(src); if (!string.IsNullOrEmpty(src.OnBuyDateString)) { dest.OnBuyDate = src.OnBuyDateString.ConvertToDateTime(); } }
public void Validate_truck_model_should_return_true() { // Arrange TruckModel truck = new TruckModel() { Code = "TMOC", Parent = null, Duration = 0.5m, Latitude = 14, Longitude = 40, NumberPlate = "MOCKTRK-1", Radius = 10m }; // Act var result = _wl.ValidateTruckModel(truck); // Assert Assert.IsTrue(result); }
public ActionResult Delete(TruckModel truckModel) { using (TruckBAL truckBAL = new TruckBAL(ContextInfo)) { truckBAL.Delete(truckModel); if (truckModel.HasErrorByType()) { truckBAL.GetTruckModel(truckModel); // truckBAL.PrepareTruckModel(truckModel); } } return(View(truckModel)); }
// GET: Truck/Edit/5 public ActionResult Edit(string id, BaseModel baseModel) { TruckModel truckModel = new TruckModel(); truckModel.CopyBaseModel(baseModel); truckModel.Id = id; using (TruckBAL truckBAL = new TruckBAL(ContextInfo)) { truckBAL.GetTruckModel(truckModel); truckBAL.PrepareTruckModel(truckModel); } return(View(truckModel)); }