public ActionResult Create() { var username = User.Identity.Name; var coworker = new Coworker(); if (!User.IsInRole(LWSFRoles.admin)) { coworker.Username = username; var vol = db.Volunteers.Where(v => v.Email == username); if (vol == null || vol.Count() == 0) { var stud = db.NewStudents.Where(s => s.Email == username); if (stud == null || stud.Count() == 0) { } else { coworker.Name = stud.SingleOrDefault().Name; coworker.Gender = (stud.SingleOrDefault().Gender == SystemGender.singleMale) ? 1 : 0; coworker.Email = stud.SingleOrDefault().Email; coworker.Phone = stud.SingleOrDefault().Phone; } } else { coworker.Name = vol.SingleOrDefault().Name; coworker.Gender = (vol.SingleOrDefault().Gender == SystemGender.singleMale) ? 1 : 0; coworker.Email = vol.SingleOrDefault().Email; coworker.Phone = vol.SingleOrDefault().Phone; } } return(View(coworker)); }
public async Task <WorkingTime> GetWorkingTimeCoworkerAsync(Coworker coworker) { WorkingTime workingTime = null; // http://localhost:63491/api/workingTime?IdMandant=8dc0122e-5a47-44d5-a0ef-02325c5d7956&IdCoworker=b639dacf-8307-4ef0-9bea-7addcb8bbe62 string resource = String.Format("{0}workingTime?IdMandant={1}&IdCoworker={2}", Constants.RestUrl, coworker.IdMandant, coworker.Id); var uri = new Uri(string.Format(resource, string.Empty)); try { var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); workingTime = JsonConvert.DeserializeObject <WorkingTime>(content); } else { WorkingTime wt = new WorkingTime(); workingTime = wt; } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } return(workingTime); }
// Zeiterfassung public async Task <Coworker> GetCoworkerAsync(string loginName) { Coworker coworker = null; // http://localhost:63491/api/coworker?loginName=h.davatz%40gmx.ch string resource = String.Format("{0}coworker?loginname={1}", Constants.RestUrl, loginName); var uri = new Uri(string.Format(resource, string.Empty)); try { var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); coworker = JsonConvert.DeserializeObject <Coworker>(content); } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } return(coworker); }
public ActionResult DeleteConfirmed(int id) { Coworker coworker = web_db.Coworkers.Find(id); web_db.Coworkers.Remove(coworker); web_db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Coworker coworker) { if (ModelState.IsValid) { web_db.Entry(coworker).State = EntityState.Modified; web_db.SaveChanges(); return(RedirectToAction("Index")); } return(View(coworker)); }
public override void OnNavigatedTo(NavigationParameters parameters) { if (parameters != null && parameters.ContainsKey("coworker")) { Coworker coworker = parameters["coworker"] as Coworker; if (coworker != null) { Coworker = coworker; } } }
public ActionResult Create(Coworker coworker) { if (ModelState.IsValid) { web_db.Coworkers.Add(coworker); web_db.SaveChanges(); return(RedirectToAction("Index")); } return(View(coworker)); }
public RestService() { CoworkerStorage coStore = new CoworkerStorage(); Coworker savedCoworker = coStore.LoadCoworker(); if (savedCoworker == null) { return; } SetClient(savedCoworker.LoginId, savedCoworker.Password); }
public Task <int> SaveCoworkerAsync(Coworker item) { if (item.Id != Guid.Empty) { return(database.UpdateAsync(item)); } else { item.Id = Guid.NewGuid(); return(database.InsertAsync(item)); } }
private async void SetUIHandlers() { DayDate.Date = DateTime.Now; _dateSelected = DayDate.Date; _user = await App.Database.GetCoworker(); if (_user != null) { await LoadList(0); } }
static void Main() { Console.WriteLine("PERSON OBJECT OUTPUT"); Person p = new Customer(); Customer o = (Customer)p; o.GetInfo(); Console.WriteLine(); Console.WriteLine("EMPLOYEE OBJECT OUTPUT"); Employee e = new Employee(); e.GetInfo(); Console.WriteLine(); Console.WriteLine("CO-WORKER OUTPUT"); Coworker cw = new Coworker(); cw.GetInfo(); Console.WriteLine(); Console.WriteLine("CUSTOMER OBJECT OUTPUT"); Customer c = new Customer(); c.GetInfo(); Console.WriteLine(); Console.WriteLine("CITIZEN OBJECT OUTPUT"); Citizen cz = new Citizen(); cz.GetInfo(); Console.WriteLine(); // Polymorphism in action //Why are we able to add these three different types to our list? List <Person> people = new List <Person>(); people.Add(p); people.Add(e); people.Add(c); people.Add(cw); Console.WriteLine(); Console.WriteLine("Print from the foreach Loop"); foreach (Person n in people) { //Which version of getInfo() is being used? n.GetInfo(); Console.WriteLine(); } }
public async Task <ActionResult <int> > Create([FromBody] Coworker newCoworker) { if (this._context.Coworkers.Any(x => x.Name == newCoworker.Name)) { return(BadRequest("Coworker with such name already exisits")); } this._context.Coworkers.Add(newCoworker); await this._context.SaveChangesAsync(); return(Ok(newCoworker.Id)); }
virtual public void SaveCoworker(Coworker coworker) { string s = DependencyService.Get <IFileHelper>().GetLocalFilePath("TimedocSQLite.db3"); using (SQLiteConnection connection = new SQLiteConnection(s)) { if (connection.Table <Coworker>().Count() > 0) { throw new InvalidOperationException("There already exist an Coworker in the database!"); } connection.Insert(coworker); } }
virtual public void DeleteCoworker(Coworker coworker) { string s = DependencyService.Get<IFileHelper>().GetLocalFilePath("TimedocSQLite.db3"); // using (SQLiteConnection connection = new SQLiteConnection(AppConfigurationController.DBPath)) using (SQLiteConnection connection = new SQLiteConnection(s)) { if (connection.Table<Coworker>().Count() <= 0) { throw new InvalidOperationException("There exist no Coworker in the database"); } connection.Delete(coworker); } }
private void btnOk_Click(object sender, EventArgs e) { txtLastName.Text = txtLastName.Text.Replace(" ", ""); txtFirstName.Text = txtFirstName.Text.Replace(" ", ""); txtMiddleName.Text = txtMiddleName.Text.Replace(" ", ""); if (txtLastName.Text == string.Empty || txtFirstName.Text == string.Empty || txtMiddleName.Text == string.Empty || txtPN.Text == string.Empty || txtLogin.Text == string.Empty || txtPassword.Text == string.Empty || txtRepeatPass.Text == string.Empty) { MetroFramework.MetroMessageBox.Show(this, "Все поля должны быть заполнены", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!txtPassword.Text.Equals(txtRepeatPass.Text)) { MetroFramework.MetroMessageBox.Show(this, "Пароли не совпадают", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (_coworkers.FirstOrDefault(x => x.Login == txtLogin.Text) != null) { MetroFramework.MetroMessageBox.Show(this, "Пользователь с таким логином уже существует", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Coworker coworker = new Coworker(txtLogin.Text, txtPassword.Text, txtPN.Text, txtFirstName.Text, txtLastName.Text, txtMiddleName.Text, Enums.UserType.User); using (Context context = new Context()) { try { context.Coworkers.Add(coworker); context.SaveChanges(); MetroFramework.MetroMessageBox.Show(this, $"Пользователь {coworker.LastName} создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } catch { MetroFramework.MetroMessageBox.Show(this, "Ошибка БД", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Close(); }
private void SelectedItem(Coworker coworker) { try { if (coworker == null) { return; } var p = new NavigationParameters(); p.Add("coworker", coworker); _navigationService.NavigateAsync("CoworkerDetails", p, animated: false); } catch (Exception ex) { } }
protected async override void OnAppearing() { base.OnAppearing(); _user = await App.Database.GetCoworker(); if (_user == null) { var tabbedPage = this.Parent as MainTabbedPage; tabbedPage.SwitchTab(3); } else { DayDate.Date = DateTime.Now; _dateSelected = DayDate.Date; await LoadList(0); } }
public void PlaceBids(int lotteryId, IEnumerable <CoworkerBid> bids) { var lottery = this._context.Lotteries.Include(x => x.UserBids).First(x => x.Id == lotteryId); if (lottery.IsFinished) { throw new LotteryIsFinishedException(); } foreach (var bid in bids) { var coworker = new Coworker { Id = bid.CoworkerId }; this._context.Coworkers.Attach(coworker).State = EntityState.Unchanged; var user = this._currentUserAccessor.GetCurrentUser(); var existingBid = lottery.UserBids.FirstOrDefault(x => x.CoworkerId == bid.CoworkerId && x.UserId == user.Id); if (existingBid == null) { var userBid = new UserBid() { LotteryId = lotteryId, Lottery = lottery, Bid = bid.BidAmmount, CoworkerId = bid.CoworkerId, Coworker = coworker, User = user }; lottery.UserBids.Add(userBid); } else { existingBid.Bid = bid.BidAmmount; } } this._context.SaveChanges(); }
public static void Main() { //https://www.codewars.com/kata/meeting/train/csharp //makes this string uppercase //gives it sorted in alphabetical order by last name. //When the last names are the same, sort them by first name. //Last name and first name of a guest come in the result between parentheses separated by a comma. //Ex: //input = "Fred:Corwill;Wilfred:Corwill;Barney:Tornbull;Betty:Tornbull;Bjon:Tornbull;Raphael:Corwill;Alfred:Corwill"; //output = "(CORWILL, ALFRED)(CORWILL, FRED)(CORWILL, RAPHAEL)(CORWILL, WILFRED)(TORNBULL, BARNEY)(TORNBULL, BETTY)(TORNBULL, BJON)" string input = Console.ReadLine(); var people = input.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.ToUpper()).ToList(); var listOfCoworkers = new List <Coworker>(); foreach (var person in people) { var names = person.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries).ToArray(); var currentPerson = new Coworker() { firstName = names[0], lastName = names[1] }; listOfCoworkers.Add(currentPerson); } listOfCoworkers = listOfCoworkers.OrderBy(x => x.lastName).ThenBy(x => x.firstName).ToList(); var listOfNames = new List <string>(); foreach (var worker in listOfCoworkers) { string currentName = $"({worker.lastName}, {worker.firstName})"; listOfNames.Add(currentName); } string outPut = string.Join("", listOfNames); Console.WriteLine(outPut); }
public async Task OnLogin(object o, EventArgs e) { CoworkerStorage coStore = new CoworkerStorage(); var user = coStore.LoadCoworker(); if (user == null) { Coworker coworker = new Coworker(); coworker.LoginId = LoginId.Text; coworker.Password = Password.Text; // Basic-http App.restManager = new RestManager(new Web.RestService(coworker.LoginId.ToLower(), coworker.Password)); Coworker rc = await App.restManager.GetCoworkerAsync(coworker.LoginId.ToLower()); if (rc != null) { coworker.Id = rc.Id; coworker.IdMandant = rc.IdMandant; coworker.IsValid = true; coStore.SaveCoworker(coworker); btnLogin.Text = "Abmelden"; DependencyService.Get <IMessage>().ShortAlert("Anmeldung erfolgreich."); } else { DependencyService.Get <IMessage>().ShortAlert("Anmeldung nicht erfolgreich."); } } else { LoginId.Text = string.Empty; Password.Text = string.Empty; btnLogin.Text = "Anmelden"; coStore.DeleteCoworker(user); } }
public Task <int> DeleteCoworkerAsync(Coworker item) { return(database.DeleteAsync(item)); }
public ViewResult Details(int id) { Coworker coworker = web_db.Coworkers.Find(id); return(View(coworker)); }
public MainForm(Coworker coworker) : this() { _user = coworker; }
public ActionResult Delete(int id) { Coworker coworker = web_db.Coworkers.Find(id); return(View(coworker)); }
public ViewResult Profile(int id) { Coworker coworker = web_db.Coworkers.Find(id); return(View(coworker)); }
public Task <WorkingTime> GetWorkingTimeCoworkerAsync(Coworker user) { return(restService.GetWorkingTimeCoworkerAsync(user)); }