public ActionResult Create([Bind(Include = "FullName,Address,Phone,Email,Vat,Note,Description")] PrivateCustomer privateCustomer) { if (ModelState.IsValid) { privateCustomer.PrivateCustomerID = Guid.NewGuid(); privateCustomer.DateCreated = DateTime.Now; privateCustomer.DateModified = privateCustomer.DateCreated; privateCustomer.CreatedBy = Guid.Parse(User.Identity.GetUserId()); privateCustomer.ModifiedBy = privateCustomer.CreatedBy; db.PrivateCustomer.Add(privateCustomer); db.SaveChanges(); Customers customers = new Customers(); customers.CustomerID = Guid.NewGuid(); customers.DateCreated = privateCustomer.DateCreated; customers.DateModified = privateCustomer.DateModified; customers.CreatedBy = privateCustomer.CreatedBy; customers.ModifiedBy = privateCustomer.ModifiedBy; customers.PrivateCustomerID = privateCustomer.PrivateCustomerID; db.Customers.Add(customers); db.SaveChanges(); return(RedirectToAction("Index", "Customers")); } return(View(privateCustomer)); }
public ActionResult Create([Bind(Include = "FullName,Address,Phone,Email,Vat,Note,Description")] Company company) { if (ModelState.IsValid) { company.CompanyID = Guid.NewGuid(); company.DateCreated = DateTime.Now; company.DateModified = company.DateCreated; company.CreatedBy = Guid.Parse(User.Identity.GetUserId()); // tole je za userID company.ModifiedBy = company.CreatedBy; //company.UserName = User.Identity.GetUserName() db.Company.Add(company); db.SaveChanges(); Customers customers = new Customers(); customers.CustomerID = Guid.NewGuid(); customers.DateCreated = company.DateCreated; customers.DateModified = company.DateModified; customers.CreatedBy = company.CreatedBy; customers.ModifiedBy = company.ModifiedBy; customers.CompanyID = company.CompanyID; db.Customers.Add(customers); db.SaveChanges(); return(RedirectToAction("Index", "Customers")); } return(View(company)); }
public ActionResult Create(ImageEditorViewModel model) { try { if (ModelState.IsValid) { BrunaContext db = new BrunaContext(); var fileModel = WebFileViewModel.getEntityModel(model.FileImage); db.WebFiles.Add(fileModel); db.SaveChanges(); var entity = ImageEditorViewModel.getEnityModel(model); entity.WebImageId = fileModel.Id; entity.OrderNo = db.Galleries.Count() > 0 ? db.Galleries.Max(x => x.OrderNo) + 1 : 1; db.Galleries.Add(entity); db.SaveChanges(); return(Json(new { success = true, Caption = model.Caption })); //ModelState.AddModelError("", "Uspešno ste naložili sliko."); //return RedirectToAction("Index", "Gallery"); } return(Json(new { success = false, ValidationMessage = "Please check validation messages" })); //ViewBag.errorMessage = "Prišlo je do napake."; //return View(); } catch (Exception) { return(Json(new { success = false, ExceptionMessage = "Some error here" })); } }
public ActionResult Create([Bind(Include = "Name,Description")] ContainerTypes containerTypes) { if (ModelState.IsValid) { containerTypes.ContainerTypeID = Guid.NewGuid(); containerTypes.DateCreated = DateTime.Now; containerTypes.DateModified = containerTypes.DateCreated; containerTypes.CreatedBy = Guid.Parse(User.Identity.GetUserId()); // tole je za userID containerTypes.ModifiedBy = containerTypes.CreatedBy; db.ContainerTypes.Add(containerTypes); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(containerTypes)); }
public ActionResult Create([Bind(Include = "Name,Description")] TransportationStatusTypes transportationStatusTypes) { if (ModelState.IsValid) { transportationStatusTypes.TransportationTypeStatusID = Guid.NewGuid(); transportationStatusTypes.DateCreated = DateTime.Now; transportationStatusTypes.DateModified = transportationStatusTypes.DateCreated; transportationStatusTypes.CreatedBy = Guid.Parse(User.Identity.GetUserId()); transportationStatusTypes.ModifiedBy = transportationStatusTypes.CreatedBy; db.TransportationStatusTypes.Add(transportationStatusTypes); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(transportationStatusTypes)); }
public JsonResult ChangeActive(int Id, bool status) { BrunaContext db = new BrunaContext(); var entity = db.Galleries.Find(Id); entity.IsActive = status; db.SaveChanges(); return(Json(entity.Title)); }
public ActionResult Create([Bind(Include = "CompanyID,PrivateCustomerID,Description")] Customers customers) { if (ModelState.IsValid) { customers.CustomerID = Guid.NewGuid(); customers.DateCreated = DateTime.Now; customers.DateModified = customers.DateCreated; customers.CreatedBy = Guid.Parse(User.Identity.GetUserId()); customers.ModifiedBy = customers.CreatedBy; db.Customers.Add(customers); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CompanyID = new SelectList(db.Company, "CompanyID", "FullName", customers.CompanyID); ViewBag.PrivateCustomerID = new SelectList(db.PrivateCustomer, "PrivateCustomerID", "FullName", customers.PrivateCustomerID); return(View(customers)); }
public ActionResult Create([Bind(Include = "CostID,TransportationLogID,Description")] DrivingCosts drivingCosts) { if (ModelState.IsValid) { drivingCosts.DrivingCostID = Guid.NewGuid(); drivingCosts.DateCreated = DateTime.Now; drivingCosts.DateModified = drivingCosts.DateCreated; drivingCosts.CreatedBy = Guid.Parse(User.Identity.GetUserId()); drivingCosts.ModifiedBy = drivingCosts.CreatedBy; db.DrivingCosts.Add(drivingCosts); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", drivingCosts.CostID); ViewBag.TransportationLogID = new SelectList(db.TransportationLog, "TransportationLogID", "Location", drivingCosts.TransportationLogID); return(View(drivingCosts)); }
public ActionResult Create([Bind(Include = "VehicleID,CostID,Description")] VehicleCosts vehicleCosts) { if (ModelState.IsValid) { vehicleCosts.VehicleCostID = Guid.NewGuid(); vehicleCosts.DateCreated = DateTime.Now; vehicleCosts.DateModified = vehicleCosts.DateCreated; vehicleCosts.CreatedBy = Guid.Parse(User.Identity.GetUserId()); vehicleCosts.ModifiedBy = vehicleCosts.CreatedBy; db.VehicleCosts.Add(vehicleCosts); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", vehicleCosts.CostID); ViewBag.VehicleID = new SelectList(db.Vehicles, "VehicleID", "Name", vehicleCosts.VehicleID); return(View(vehicleCosts)); }
public ActionResult Create([Bind(Include = "ContainerTypeID,CompanyID,Name,Label,Volume,Note,Description")] Containers containers) { if (ModelState.IsValid) { containers.ContainerID = Guid.NewGuid(); containers.DateCreated = DateTime.Now; containers.DateModified = containers.DateCreated; containers.CreatedBy = Guid.Parse(User.Identity.GetUserId()); // tole je za userID containers.ModifiedBy = containers.CreatedBy; db.Containers.Add(containers); db.SaveChanges(); return(RedirectToAction("Index", "Vehicles")); } ViewBag.CompanyID = new SelectList(db.Company, "CompanyID", "FullName", containers.CompanyID); ViewBag.ContainerTypeID = new SelectList(db.ContainerTypes, "ContainerTypeID", "Name", containers.ContainerTypeID); return(View(containers)); }
public ActionResult Create([Bind(Include = "TransportationTypeStatusID,TransportationLogID,Date,Note,Description")] TransportationStatus transportationStatus) { if (ModelState.IsValid) { transportationStatus.TransportationStatusID = Guid.NewGuid(); transportationStatus.DateCreated = DateTime.Now; transportationStatus.DateModified = transportationStatus.DateCreated; transportationStatus.CreatedBy = Guid.Parse(User.Identity.GetUserId()); transportationStatus.ModifiedBy = transportationStatus.CreatedBy; db.TransportationStatus.Add(transportationStatus); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TransportationLogID = new SelectList(db.TransportationLog, "TransportationLogID", "Location", transportationStatus.TransportationLogID); ViewBag.TransportationTypeStatusID = new SelectList(db.TransportationStatusTypes, "TransportationTypeStatusID", "Name", transportationStatus.TransportationTypeStatusID); return(View(transportationStatus)); }
public ActionResult Create([Bind(Include = "TransportationLogID,FirstName,LastName,Address,PostCode,City,Date,Note,Attachment,Description")] HouseholdTransportation householdTransportation, string LogID) { if (ModelState.IsValid) { householdTransportation.HouseholdTransportationID = Guid.NewGuid(); householdTransportation.TransportationLogID = Guid.Parse(LogID); householdTransportation.DateCreated = DateTime.Now; householdTransportation.DateModified = householdTransportation.DateCreated; householdTransportation.CreatedBy = Guid.Parse(User.Identity.GetUserId()); householdTransportation.ModifiedBy = householdTransportation.CreatedBy; db.HouseholdTransportation.Add(householdTransportation); db.SaveChanges(); return(RedirectToAction("Index")); } // ViewBag.TransportationLogID = new SelectList(db.TransportationLog, "TransportationLogID", "Location", householdTransportation.TransportationLogID); return(View(householdTransportation)); }
public ActionResult Create([Bind(Include = "CompanyID,Name,RegPlate,Brand,Vin,Gvw,MassCargo,Type,DateReg,DateMot,Note,Description")] Vehicles vehicles) { if (ModelState.IsValid) { vehicles.VehicleID = Guid.NewGuid(); vehicles.DateCreated = DateTime.Now; vehicles.DateModified = vehicles.DateCreated; vehicles.CreatedBy = Guid.Parse(User.Identity.GetUserId()); vehicles.ModifiedBy = vehicles.CreatedBy; db.Vehicles.Add(vehicles); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CompanyID = new SelectList(db.Company, "CompanyID", "FullName", vehicles.CompanyID); //ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", vehicles.CostID); return(View(vehicles)); }
public ActionResult Create([Bind(Include = "ContainerID,VehicleID,CargoID,CustomerID,CostID,Date,Location,Note,Description")] TransportationLog transportationLog, bool checkHousehold = false, bool checkCosts = false) { if (ModelState.IsValid) { transportationLog.TransportationLogID = Guid.NewGuid(); transportationLog.DateCreated = DateTime.Now; transportationLog.DateModified = transportationLog.DateCreated; transportationLog.CreatedBy = Guid.Parse(User.Identity.GetUserId()); transportationLog.ModifiedBy = transportationLog.CreatedBy; transportationLog.Active = true; db.TransportationLog.Add(transportationLog); db.SaveChanges(); // CHECKBOX za COSTS! /*if (checkCosts == true) * { * Costs costs = new Costs(); * costs.CostID = Guid.NewGuid(); * * costs.DateCreated = transportationLog.DateCreated; * costs.DateModified = transportationLog.DateModified; * * costs.CreatedBy = transportationLog.CreatedBy; * costs.ModifiedBy = transportationLog.ModifiedBy; * * costs.Amount = amount; * costs.Date = transportationLog.Date; * costs.Note = note; * costs.CostTypeID * * * * db.Costs.Add(costs); * db.SaveChanges(); * }*/ // tukaj dodaj za transporation status zapis //Guid latestTransporationLogID = transportationLog.TransportationLogID; TransportationStatus transportationStatus = new TransportationStatus(); transportationStatus.TransportationStatusID = Guid.NewGuid(); transportationStatus.DateCreated = transportationLog.DateCreated; transportationStatus.DateModified = transportationLog.DateModified; transportationStatus.CreatedBy = transportationLog.CreatedBy; transportationStatus.ModifiedBy = transportationLog.ModifiedBy; transportationStatus.Date = DateTime.Now; transportationStatus.TransportationTypeStatusID = Guid.Parse("cbaa33cc-ed89-448d-a371-72bafa5a4ff8"); transportationStatus.TransportationLogID = transportationLog.TransportationLogID; db.TransportationStatus.Add(transportationStatus); db.SaveChanges(); // CHECKBOX za HOUSEHOLD! if (checkHousehold == true) { return(RedirectToAction("Create", "HouseholdTransportation", new { LogID = transportationLog.TransportationLogID })); } return(RedirectToAction("Index")); } ViewBag.CargoID = new SelectList(db.CargoTypes, "CargoID", "Name", transportationLog.CargoID); ViewBag.ContainerID = new SelectList(db.Containers, "ContainerID", "Name", transportationLog.ContainerID); //ViewBag.CostID = new SelectList(db.Costs, "CostID", "Note", transportationLog.CostID); ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Description", transportationLog.CustomerID); ViewBag.VehicleID = new SelectList(db.Vehicles, "VehicleID", "Name", transportationLog.VehicleID); return(View(transportationLog)); }
public ActionResult Create([Bind(Include = "CostTypeID,Amount,Date,Note,Description")] Costs costs, string VehicleID, string TransportationLogID) { if (ModelState.IsValid) { costs.CostID = Guid.NewGuid(); costs.DateCreated = DateTime.Now; costs.DateModified = costs.DateCreated; costs.CreatedBy = Guid.Parse(User.Identity.GetUserId()); costs.ModifiedBy = costs.CreatedBy; db.Costs.Add(costs); db.SaveChanges(); // Da shranis v tabelo VehicleCosts if (VehicleID != null) { Guid latestCostID = costs.CostID; VehicleCosts vehicleCosts = new VehicleCosts(); vehicleCosts.VehicleCostID = Guid.NewGuid(); vehicleCosts.DateCreated = costs.DateCreated; vehicleCosts.DateModified = costs.DateModified; vehicleCosts.CreatedBy = costs.CreatedBy; vehicleCosts.ModifiedBy = costs.ModifiedBy; vehicleCosts.VehicleID = Guid.Parse(VehicleID); vehicleCosts.CostID = latestCostID; db.VehicleCosts.Add(vehicleCosts); db.SaveChanges(); return(RedirectToAction("Details/" + VehicleID, "Vehicles")); } // Da shranis v tabelo TransporationLog if (TransportationLogID != null) { Guid latestCostID = costs.CostID; DrivingCosts drivingCosts = new DrivingCosts(); drivingCosts.DrivingCostID = Guid.NewGuid(); drivingCosts.DateCreated = costs.DateCreated; drivingCosts.DateModified = costs.DateModified; drivingCosts.CreatedBy = costs.CreatedBy; drivingCosts.ModifiedBy = costs.ModifiedBy; drivingCosts.TransportationLogID = Guid.Parse(TransportationLogID); drivingCosts.CostID = latestCostID; db.DrivingCosts.Add(drivingCosts); db.SaveChanges(); return(RedirectToAction("Details/" + TransportationLogID, "TransportationLog")); } return(RedirectToAction("Index")); } ViewBag.CostTypeID = new SelectList(db.CostTypes, "CostTypeID", "Name", costs.CostTypeID); return(View(costs)); }