public IHttpActionResult Register([FromBody] Users user) { System.Web.Http.Results.StatusCodeResult status; using (IUMdbEntities entities = new IUMdbEntities()) { #region Validation #region checkIfUserIsNull if (user == null) { status = new System.Web.Http.Results.StatusCodeResult(HttpStatusCode.Conflict, this); return(status); } #endregion #region checkIfUsernameIsTaken bool checkIfUsernameIsTaken = entities.Users .Any(e => e.Username == user.Username); if (checkIfUsernameIsTaken) { status = new System.Web.Http.Results.StatusCodeResult(HttpStatusCode.Conflict, this); return(status); } #endregion #endregion CryptoService cryptoService = new CryptoService(); string hashedPassword = cryptoService.GetHashedString(user.Password); Users newUser = new Users() { Username = user.Username, Password = hashedPassword, GoogleId = user.GoogleId }; entities.Users.Add(newUser); entities.SaveChanges(); Users dbUser = entities.Users .Where(e => e.Username == user.Username) .First(); UserRoles employeeRole = entities.UserRoles .Where(e => e.RoleName == "Employee") .First(); Workplaces newWorkplace = new Workplaces() { UserId = dbUser.Id, UserRoleId = employeeRole.Id }; entities.Workplaces.Add(newWorkplace); entities.SaveChanges(); status = new System.Web.Http.Results.StatusCodeResult(HttpStatusCode.Created, this); return(status); } }
public void Clear() { lock (Dwellers) Dwellers.Clear(); Homes.Clear(); Cafes.Clear(); Workplaces.Clear(); }
public Workplace(DateTime dateOfEmployment, string department, Workplaces emplWorkplace, float yearSalary, int phoneNumber, int roomNumber) { DateOfEmployment = dateOfEmployment; EmplWorkplace = emplWorkplace; Department = department; YearSalary = yearSalary; if (emplWorkplace.Equals(Workplaces.Asystent)) { PhoneNumber = phoneNumber; } else { PhoneNumber = 0; } if (emplWorkplace.Equals(Workplaces.Dyrektor)) { RoomNumber = roomNumber; } else { RoomNumber = 0; } }
public SmallEditor() { InitializeComponent(); DBBodyTypes = new BodyTypes(); DBClasses = new Classes(); DBColors = new Colors(); DBGearTypes = new GearTypes(); DBLanguages = new Languages(); DBManafacturers = new Manafacturers(); DBWorkplaces = new Workplaces(); }
public void FilterCollection(string filteringSubstring) { filteringSubstring = filteringSubstring.Trim().ToLower(); if (string.IsNullOrEmpty(filteringSubstring)) { FilteredWorkplaces.Clear(); return; } FilteredWorkplaces = Workplaces.Where(x => x.Title.ToLower().Contains(filteringSubstring)).ToList(); }
//private void CheckNewLocation(IDweller dweller, IBuilding obj) //{ // if (dweller.Position.Value == obj.Position.Value) // { // // yep // dweller.EnterBuilding(obj); // } //} public void Add(IBuilding building) { switch (building) { case IHome home: Homes.Add(home); break; case IWorkplace workplace: Workplaces.Add(workplace); break; case ICafe cafe: Cafes.Add(cafe); break; } }
public ElementControlService() { DBAutomobilesData = new AutomobilesData(); DBClients = new Clients(); DBOffices = new Offices(); DBSelledCars = new SelledCars(); DBWorkers = new Workers(); DBBodyTypes = new BodyTypes(); DBClasses = new Classes(); DBColors = new Colors(); DBCountries = new Countries(); DBGearTypes = new GearTypes(); DBLanguages = new Languages(); DBManafacturers = new Manafacturers(); DBWorkplaces = new Workplaces(); }
public MainForm() { InitializeComponent(); // ConnectionWizard ConWiz = new ConnectionWizard(); // ConWiz.StartPosition = FormStartPosition.CenterScreen; // ConWiz.ShowDialog(); PageID = DatabaseControlService.LastPage; About = new AboutForm(); //Editor Forms DBAutomobileEditor = new AutomobilesEditor(); DBClientEditor = new ClientsEditor(); DBOfficeEditor = new OfficesEditor(); DBOrderEditor = new OrdersEditor(); DBPresenceCarEditor = new PresenceCarsEditor(); DBSellEditor = new SellsEditor(); DBWorkerEditor = new WorkersEditor(); //Tables DBAutomobilesData = new AutomobilesData(); DBBodyTypes = new BodyTypes(); DBClients = new Clients(); DBColors = new Colors(); DBCountries = new Countries(); DBLanguages = new Languages(); DBManafacturers = new Manafacturers(); DBOffices = new Offices(); DBOrders = new Orders(); DBPresenceCars = new PresenceCars(); DBSelledCars = new SelledCars(); DBSells = new Sells(); DBWorkers = new Workers(); DBWorkplaces = new Workplaces(); dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.MultiSelect = false; buttonInsert.Enabled = false; buttonUpdate.Enabled = false; buttonDelete.Enabled = false; ShowDialog(); }
public SmallSelector() { InitializeComponent(); DBBodyTypes = new BodyTypes(); DBClasses = new Classes(); DBColors = new Colors(); DBCountries = new Countries(); DBGearTypes = new GearTypes(); DBLanguages = new Languages(); DBManafacturers = new Manafacturers(); DBWorkplaces = new Workplaces(); DBSmallEditor = new SmallEditor(); DBCountryEditor = new CountriesEditor(); dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.MultiSelect = false; }
public async Task DeleteWorkplace(object wp) { try { var workplace = wp as Workplace; if (workplace == null) { return; } IsBusy = true; await _workplacesManager.DeleteWorkplace(workplace.Id); Workplaces.Remove(workplace); IsBusy = false; } catch (Exception ex) { HandleError(ex); } }
public Workplaces GetWorkplaces() { workplaces = new Workplaces(workplacesTrans); return(workplaces); }