/// <summary> /// Create a Company /// </summary> /// <param name="company"></param> /// <returns>The Created Company</returns> public async Task <Models.Company> CreateCompany(Models.Company company) { await dbContext.Companys.AddAsync(company); dbContext.SaveChanges(); return(await this.GetCompanyByISIN(company.ISIN)); }
public IActionResult Create(CreateModel Emp) { if (!ModelState.IsValid) { return(BadRequest()); } if (Emp == null || Emp.Employee == null || string.IsNullOrEmpty(Emp.Employee.LastName)) { return(NotFound()); } int checkExist = (from e in companyDB.Employees where e.LastName == Emp.Employee.LastName && e.FirstName == Emp.Employee.FirstName select e).Count(); if (0 < checkExist) { return(BadRequest()); } if (Emp.DepartmentName != null) { Emp.Employee.DepartmentId = companyDB.GetDepartmentIdByName(Emp.DepartmentName); } companyDB.Employees.Add(Emp.Employee); companyDB.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Name,Email,Password")] CompanyViewModel companyVM) { if (ModelState.IsValid) { Company company = new Company(); if (!company.UniqueEmail(companyVM.Email)) { ViewBag.Verify = "This email already exists!"; return(View(companyVM)); } company.Name = companyVM.Name; company.Email = companyVM.Email; company.Password = BCrypt.Net.BCrypt.HashPassword(companyVM.Password); db.Companies.Add(company); db.SaveChanges(); return(RedirectToAction("Login")); } return(View(companyVM)); }
public Employee CreateEmployee(string firstName, string lastName, string email, decimal salary = 0) { var employee = Employee.Create(firstName, lastName, email, salary); context.Employees.Add(employee); context.SaveChanges(); return(employee); }
public Department CreateDepartment(string name, string description = "") { var department = Department.Create(name, description); context.Departments.Add(department); context.SaveChanges(); return(department); }
public ActionResult Create([Bind(Include = "CompanyId,Name,Ticker,Asset,Debt,Liquidity,Assessment")] Company company) { if (ModelState.IsValid) { db.Companies.Add(company); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(company)); }
public ActionResult Create([Bind(Include = "ID,Name,Description")] Reclamo reclamo) { if (ModelState.IsValid) { db.Reclamos.Add(reclamo); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reclamo)); }
public ActionResult Create([Bind(Include = "ID,Name,Age")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "ID,Name,Email,Phone,BookingTime,ServiceID")] Booking booking) { if (ModelState.IsValid) { db.Bookings.Add(booking); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ServiceID = new SelectList(db.Services, "ID", "Title", booking.ServiceID); return(View(booking)); }
/// <summary> /// Creates a Ticker /// </summary> /// <param name="ticker">the ticker to be created</param> /// <returns>the ticker</returns> public async Task <Ticker> CreateTicker(Ticker ticker) { //If ticker already exists return that ticker as ticker names are unique var existing = await this.GetTickerByName(ticker.Name); if (existing != null) { return(existing); } await dbContext.Tickers.AddAsync(ticker); dbContext.SaveChanges(); return(await this.GetTickerByName(ticker.Name)); }
/// <summary> /// Creates a new entry in the company_exchange table /// </summary> /// <param name="companyExchange">the to-be-created company</param> /// <returns>the created object</returns> public async Task <CompanyExchange> CreateCompanyExchange(CompanyExchange companyExchange) { await dbContext.CompanyExchange.AddAsync(companyExchange); dbContext.SaveChanges(); return(companyExchange); }
public void PostBrand(Brand newBrand) { CompanyDBContext db = new CompanyDBContext(); db.Brands.Add(newBrand); db.SaveChanges(); }
public void RemoveEntity <T>(T Entity) where T : class { using (var CompanyDBContext = new CompanyDBContext()) { CompanyDBContext.Set <T>().Remove(Entity); CompanyDBContext.SaveChanges(); } }
public void PutBrand(Brand brandData) { CompanyDBContext db = new CompanyDBContext(); var existingBrand = db.Brands.Where(temp => temp.BrandID == brandData.BrandID).FirstOrDefault(); existingBrand.BrandName = brandData.BrandName; db.SaveChanges(); }
public void DeleteBrand(long BrandID) { CompanyDBContext db = new CompanyDBContext(); var existingBrand = db.Brands.Where(temp => temp.BrandID == BrandID).FirstOrDefault(); db.Brands.Remove(existingBrand); db.SaveChanges(); }
public ActionResult Create(Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } else { List <Category> categories = db.Categories.ToList(); ViewBag.Cat = categories; List <Brand> brands = db.Brands.ToList(); ViewBag.Brand = brands; return(View()); } }
public void UpdateOrder(Order Entity) { using (var CompanyDBContext = new CompanyDBContext()) { var OldEntity = CompanyDBContext.Set <Order>().Find(Entity.Id); OldEntity.Name = Entity.Name; CompanyDBContext.SaveChanges(); } }
public IActionResult Create(DepartmentModel dep) { if (!ModelState.IsValid) { return(BadRequest()); } if (dep == null || dep.department == null || string.IsNullOrEmpty(dep.department.Name)) { return(NotFound()); } int checkExist = (from e in companyDB.Departments where e.Name == dep.department.Name select e).Count(); if (0 < checkExist) { return(BadRequest()); } companyDB.Departments.Add(dep.department); companyDB.SaveChanges(); return(RedirectToAction("Index")); }
public void UpdateWorker(Worker Entity) { using (var CompanyDBContext = new CompanyDBContext()) { var OldEntity = CompanyDBContext.Set <Worker>().Find(Entity.Id); OldEntity.Name = Entity.Name; OldEntity.Surname = Entity.Surname; OldEntity.Middlename = Entity.Middlename; OldEntity.DepartmentId = Entity.Department.Id; OldEntity.Birthday = Entity.Birthday; OldEntity.GenderId = Entity.Gender.Id; CompanyDBContext.SaveChanges(); } }
public ActionResult Create([Bind(Include = "ID,Title,Description,Duration,Spaces,Price,Rating,Availability")] ServiceViewModel serviceVM) { if (ModelState.IsValid) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <ServiceViewModel, Service>(); }); IMapper mapper = config.CreateMapper(); Service service = mapper.Map <ServiceViewModel, Service>(serviceVM); string userId = Session["User"].ToString(); service.CompanyID = Convert.ToInt32(userId); db.Services.Add(service); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.CompanyID = new SelectList(db.Companies, "ID", "Name", service.CompanyID); return(View(serviceVM)); }
public ActionResult Create([Bind(Include = "ProductID, ProductName, Price, DOP, AvailabilityStatus, CategoryID, BrandID, Active, Photo")] Product p) { if (ModelState.IsValid) { if (Request.Files.Count >= 1) { var file = Request.Files[0]; var imgBytes = new Byte[file.ContentLength]; file.InputStream.Read(imgBytes, 0, file.ContentLength); var base64String = Convert.ToBase64String(imgBytes, 0, imgBytes.Length); p.Photo = base64String; } db.Products.Add(p); db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.Categories = db.Categories.ToList(); ViewBag.Brands = db.Brands.ToList(); return(View()); } }
public ActionResult AddPhoto(Photo ph, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Content/Photos/") + file.FileName); ph.URL = file.FileName; } db.Photos.Add(ph); db.SaveChanges(); } return(RedirectToAction("Index", "Photo")); }
/// <summary> /// Creates a new Exchange /// </summary> /// <param name="exchange">The new exchange to be created</param> /// <returns>the newly create</returns> public async Task <Exchange> CreateExchange(Exchange exchange) { //if exchange already exists just return that exchange as exchange names are unique var existingExchange = await this.GetExchangeByName(exchange.Name); if (existingExchange != null) { return(existingExchange); } await dbContext.Exchange.AddAsync(exchange); dbContext.SaveChanges(); return(await this.GetExchangeByName(exchange.Name)); }
public void UpdateDepartment(Department Entity) { using (var CompanyDBContext = new CompanyDBContext()) { var OldEntity = CompanyDBContext.Set <Department>().Find(Entity.Id); OldEntity.Name = Entity.Name; if (Entity.Boss != null) { OldEntity.BossId = Entity.Boss.Id; } else { OldEntity.BossId = null; } CompanyDBContext.SaveChanges(); } }
public void SetUp() { // Insert seed data into the database using one instance of the context using (var context = new CompanyDBContext(options)) { context.Database.EnsureDeleted(); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 1, ExchangeId = 1 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 1, ExchangeId = 2 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 2, ExchangeId = 3 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 2, ExchangeId = 4 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 2, ExchangeId = 5 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 3, ExchangeId = 2 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 3, ExchangeId = 3 }); context.CompanyExchange.Add(new Models.CompanyExchange { CompanyId = 3, ExchangeId = 4 }); context.SaveChanges(); } dao = new CompanyExchangeDAO(new CompanyDBContext(options)); }
public void SetUp() { // Insert seed data into the database using one instance of the context using (var context = new CompanyDBContext(options)) { context.Database.EnsureDeleted(); context.Tickers.Add(new Ticker { CompanyId = 1, Name = "AAA" }); context.Tickers.Add(new Ticker { CompanyId = 1, Name = "GME" }); context.Tickers.Add(new Ticker { CompanyId = 2, Name = "GOOGL" }); context.Tickers.Add(new Ticker { CompanyId = 2, Name = "GOOG" }); context.Tickers.Add(new Ticker { CompanyId = 2, Name = "NFLX" }); context.Tickers.Add(new Ticker { CompanyId = 3, Name = "G" }); context.Tickers.Add(new Ticker { CompanyId = 3, Name = "D" }); context.Tickers.Add(new Ticker { CompanyId = 3, Name = "AAPL" }); context.SaveChanges(); } dao = new TickerDAO(new CompanyDBContext(options)); }
public void SetUp() { // Insert seed data into the database using one instance of the context using (var context = new CompanyDBContext(options)) { context.Database.EnsureDeleted(); context.Exchange.Add(new Exchange { Name = "New York Stock Exchange" }); context.Exchange.Add(new Exchange { Name = "Nasdaq" }); context.Exchange.Add(new Exchange { Name = "Japan Exchange Group" }); context.Exchange.Add(new Exchange { Name = "London Stock Exchange" }); context.Exchange.Add(new Exchange { Name = "Shanghai Stock Exchange" }); context.Exchange.Add(new Exchange { Name = "Hong Kong Stock Exchange" }); context.Exchange.Add(new Exchange { Name = "Euronext" }); context.Exchange.Add(new Exchange { Name = "Toronto Stock Exchange" }); context.SaveChanges(); } dao = new ExchangeDAO(new CompanyDBContext(options)); }
public void Setup() { // Insert seed data into the database using one instance of the context using (var context = new CompanyDBContext(options)) { context.Database.EnsureDeleted(); context.Companys.Add(new Models.Company { Id = 1, Name = "Company1", ISIN = "ER00001", Website = "test1.com" }); context.Companys.Add(new Models.Company { Id = 2, Name = "Company2", ISIN = "ER00002", Website = "test2.com" }); context.Companys.Add(new Models.Company { Id = 3, Name = "Company3", ISIN = "ER00003", Website = "test3.com" }); context.Companys.Add(new Models.Company { Id = 4, Name = "Company4", ISIN = "ER00004", Website = "test4.com" }); context.SaveChanges(); } dao = new CompanyDAO(new CompanyDBContext(options)); }
public void AddEmp(Employees obj) { _context.Add(obj); _context.SaveChanges(); }