public ActionResult Edit(Share share, int employeeId = 0) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); //if (!ctx.Employees.Any(e => e.Id == employeeId && e.Active == true)) //{ // ModelState.AddModelError("employeeId", "You must provide a valid employee ID in order to make this change"); //} if (ModelState.IsValid) { if (!ctx.Employees.Any(e => e.Id == employeeId && e.Active == true)) { Employee employee = ctx.Employees.Single(e => e.Id == employeeId); share.Notes = "Marked " + (share.Paid_Dues ? "paid" : "unpaid") + " by " + employee.FullName + ". Date " + DateTime.Now; db.Entry(share).State = EntityState.Modified; AuditLog log = new AuditLog() { date = DateTime.Now, message = "Share " + share.Id + " marked " + (share.Paid_Dues ? "paid" : "unpaid") + " by " + employee.FullName }; db.AuditLogs.Add(log); } else { share.Notes = "Marked " + (share.Paid_Dues ? "paid" : "unpaid") + " on date " + DateTime.Now; db.Entry(share).State = EntityState.Modified; } db.SaveChanges(); return RedirectToAction("Index"); } return View(share); }
public ActionResult Checkin(int id) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); if (!ctx.Employees.Any(e => e.Id == id && e.Active == true)){ return RedirectToAction("Index", "Search"); } return View(ctx.Employees.Single(e => e.Id == id )); }
public ActionResult EmployeeCheckedIn(int id, bool IsEntry) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); EmployeeTime checkinTime = new EmployeeTime(); checkinTime.Time = DateTime.Now; checkinTime.Entry = IsEntry; checkinTime.EmployeeId = id; ctx.EmployeeTimes.Add(checkinTime); ctx.SaveChanges(); TempData["success"] = "Employee checked " + (IsEntry ? "In" : "Out"); return RedirectToAction("Index", "Search"); }
public ActionResult EmployeeTime() { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); return View(ctx.rpt_employee_time.AsNoTracking().OrderBy(h => h.LastName).ThenBy(h => h.date_time)); }
public ActionResult Hourly() { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); return View(ctx.hourlycounts.AsNoTracking().OrderByDescending(h => h.entry_date).ThenBy(h => h.hour_slot)); //return View(ctx.hourlycounts); }
public ActionResult AddImageToPerson(int Id, int PersonId) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); var Person = ctx.People.Single(p => p.Id == PersonId); return View("AddImageToPerson",Person); }
public ActionResult Emails() { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); return View(ctx.People.Where(p=>!(p.Email == null || p.Email == "")).OrderBy(h => h.LastName).ThenBy(h => h.Email)); }
public ActionResult PersonImage(int? id) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); if (!ctx.People.Any(s => s.Id == id)) { return HttpNotFound(); } var person = ctx.People.Single(s => s.Id == id); //var ms = new System.IO.MemoryStream(person.Picture); //var img = Image.FromStream(ms); return new FileContentResult(person.Picture, "image/jpeg"); }
public ActionResult Search(String searchText) { if (String.IsNullOrWhiteSpace(searchText)) { return View(); } int shareId = -1; if (searchText.Length > 0 && !Int32.TryParse(searchText, out shareId)) { ModelState.AddModelError("ShareText", "Entry must be numerical"); return View(); } if (shareId == 99999) { return Redirect("~/Report"); } PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); if(!ctx.Shares.Any(s=>s.Id==shareId && s.Active==true)){ if (ctx.Employees.Any(e => e.Id == shareId && e.Active == true)) { return RedirectToAction("Checkin", "Employee", new { id = shareId }); } ModelState.AddModelError("ShareText", "Active Membership not Found"); return View(); } var share = from s in ctx.Shares where s.Id==shareId && s.Active==true select s; var activeShareFamilies = share.SelectMany(s=>s.ShareFamilies).Where(sf=>sf.Active); return View("Search",share.Single()); }
public ActionResult ConfirmCheckin(int[] CheckinPeople, String[] PersonEmail, int TicketCount, int CashCount, int CreditCount) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); var checkinPersonObjects = new List<Person>(); foreach (var pid in CheckinPeople) { checkinPersonObjects.Add(ctx.People.Single(p => p.Id == pid)); } if((TicketCount + CashCount + CreditCount) != checkinPersonObjects.Count(p => p.Is_Guest == true)){ ModelState.AddModelError("CheckinPeople","Cash, ticket, and credit counts do not equal guest count"); } if (!checkinPersonObjects.First().Family.ShareFamilies.First().Share.Paid_Dues) { ModelState.AddModelError("CheckinPeople", "Member dues have not been paid! Please see an employee"); } var remainingTicket = TicketCount; var remainingCash = CashCount; var remainingCredit = CreditCount; for (int i = 0; i < CheckinPeople.Length; i++) { var personId = CheckinPeople[i]; Person person = ctx.People.Single(p => p.Id == personId); var entry = new Entry() { Entry_Person = personId, Time = DateTime.Now }; if (person.Is_Guest == true) { if (remainingTicket > 0) { entry.Entry_Type = "TICKET"; remainingTicket--; } else if (remainingCash > 0) { entry.Entry_Type = "CASH"; remainingCash--; } else if (remainingCredit > 0) { entry.Entry_Type = "CREDIT"; remainingCredit--; } AuditLog log = new AuditLog() { date = DateTime.Now, message = person.FullName + " used " + entry.Entry_Type, personId = personId }; ctx.AuditLogs.Add(log); } else { entry.Entry_Type = "MEMBER"; } ctx.Entries.Add(entry); try { if (!String.IsNullOrWhiteSpace(PersonEmail[i])) { MailAddress address = new MailAddress(PersonEmail[i]); person.Email = PersonEmail[i]; } } catch (Exception) { } } if (ModelState.IsValid) { ctx.SaveChanges(); TempData["success"] = "Successfully checked in"; return RedirectToAction("Index"); } return View("ConfirmCheckin", checkinPersonObjects); }
public ActionResult EditFamilyGuestList(int? id) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); if (!ctx.Families.Any(f => f.Id == id)) { return RedirectToAction("Index"); } return View(ctx.Families.Single(f => f.Id == id)); }
public ActionResult Checkin(int Id, int[] CheckinPeople) { if (CheckinPeople == null || CheckinPeople.Length == 0) { ModelState.AddModelError("CheckinPeople","You must select a member to check in"); return Search(Id.ToString()); } PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); var checkinPersonObjects = new List<Person>(); foreach (var pid in CheckinPeople) { checkinPersonObjects.Add(ctx.People.Single(p => p.Id == pid)); } if (!checkinPersonObjects.First().Family.ShareFamilies.First().Share.Paid_Dues) { ModelState.AddModelError("CheckinPeople", "Member dues have not been paid! Please see an employee"); } if (!checkinPersonObjects.Any(p=>!p.Is_Guest.HasValue || !p.Is_Guest.Value)) { ModelState.AddModelError("CheckinPeople", "You must select a member to check in"); } if (ModelState.IsValid) { return View("ConfirmCheckin", checkinPersonObjects); } return Search(Id.ToString()); }
public ActionResult AddCheckinGuest(int Id, int[] CheckinPeople, Person Person, HttpPostedFileBase picture, String canvasPicture) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); var refPersonId = CheckinPeople[0]; var refPerson = ctx.People.Single(p => p.Id == refPersonId); if(!Person.Is_Guest.HasValue){ Person.Is_Guest = true; } Person.Family = refPerson.Family; var peopleList = CheckinPeople.ToList(); if (picture != null && picture.ContentLength > 0) { try{ var img = Image.FromStream(picture.InputStream); if (img.Height > 200 || img.Width > 200) { Size size = new Size(); if(img.Size.Height > img.Size.Width){ size.Height = 200; size.Width = (int)(img.Size.Width * (200.0 / img.Size.Height)); }else{ size.Width = 200; size.Height = (int)(img.Size.Height * (200.0 / img.Size.Width)); } img = new Bitmap(img, size); } var ms = new System.IO.MemoryStream(); img.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg); Person.Picture = ms.ToArray(); }catch(Exception e){ ModelState.AddModelError("Person.Picture","Unknown error with image " + e.Message); } } else if (canvasPicture != null && canvasPicture.Length != 0) { try { var picBytes = Convert.FromBase64String(canvasPicture.Substring(canvasPicture.IndexOf("base64,") + 7)); var memoryStream = new System.IO.MemoryStream(picBytes); //create image in order to convert to jpeg var img = Image.FromStream(memoryStream); var ms = new System.IO.MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Person.Picture = ms.ToArray(); } catch (Exception e) { ModelState.AddModelError("Picture", "Unknown error with image: " + e.Message); } } var viewModel = new GuestCheckinViewModel(); if (ModelState.IsValid) { ctx.People.Add(Person); ctx.SaveChanges(); peopleList.Add(Person.Id); viewModel.PersonIdList = peopleList.ToArray(); viewModel.Person = new Person(); TempData["success"] = "Added new guest"; ModelState.Clear(); } else { viewModel.PersonIdList = CheckinPeople; viewModel.Person = Person; } viewModel.Id = Id; if (ModelState.IsValid && Request.Form.AllKeys.Contains("checkin")) { return Checkin(Id, viewModel.PersonIdList); }else{ return View("AddGuest", viewModel); } }
public ActionResult ArchivePerson(int? id, int? delete) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); if (!ctx.People.Any(s => s.Id == delete)) { return RedirectToAction("Index"); } var person = ctx.People.Single(s => s.Id == delete); var family = person.Family; person.Family = null; family.People.Remove(person); if (family.People.Where(p=>p.Is_Guest == false).Count() == 0) { ModelState.AddModelError("id", "You must add another member first in order to remove this entry"); return Search(family.ShareFamilies.Single().Share.Id.ToString()); } AuditLog log = new AuditLog() { date = DateTime.Now, message = person.FullName + " removed from family " + family.FamilyName + ", family.id=" + family.Id + ", share=" + family.ShareFamilies.Single().Share.Id, personId = id }; ctx.AuditLogs.Add(log); if(ModelState.IsValid){ try { ctx.SaveChanges(); TempData["success"] = "Successfully archived person"; } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { foreach(var ve in eve.ValidationErrors) { ModelState.AddModelError(ve.PropertyName, ve.ErrorMessage); } } } } return Search(id.ToString()); }
public ActionResult ArchiveGuest(int? Id) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); if (!ctx.People.Any(s => s.Id == Id && s.Is_Guest.HasValue && s.Is_Guest.Value)) { return RedirectToAction("Index"); } var person = ctx.People.Single(s => s.Id == Id && s.Is_Guest.HasValue && s.Is_Guest.Value); var family = person.Family; person.Family = null; family.People.Remove(person); AuditLog log = new AuditLog() { date = DateTime.Now, message = person.FullName + " removed from family " + family.FamilyName + ", family.id=" + family.Id + ", share=" + family.ShareFamilies.Single().Share.Id, personId = Id }; ctx.SaveChanges(); TempData["success"] = "Successfully archived guest"; return new JsonResult() { Data = new { Success = true } }; }
public ActionResult AddImageToPerson(int Id, int PersonId, HttpPostedFileBase picture, String canvasPicture) { PoolDataEntitiesConnection ctx = new PoolDataEntitiesConnection(); var Person = ctx.People.Single(p => p.Id == PersonId); if (picture != null && picture.ContentLength > 0) { try { var img = Image.FromStream(picture.InputStream); if (img.Height > 320 || img.Width > 240) { Size size = new Size(); if (img.Size.Height > img.Size.Width) { size.Height = 240; size.Width = (int)(img.Size.Width * 4.0/3.0 * (240.0 / img.Size.Height)); } else { size.Width = 320; size.Height = (int)(img.Size.Height * 0.75 * (320.0 / img.Size.Width)); } img = new Bitmap(img, size); } var ms = new System.IO.MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Person.Picture = ms.ToArray(); ctx.SaveChanges(); TempData["success"] = "Successfully saved person image"; return Search(Id.ToString()); } catch (Exception e) { ModelState.AddModelError("Picture", "Unknown error with image: " + e.Message); } } else if (canvasPicture != null && canvasPicture.Length != 0) { try { var picBytes = Convert.FromBase64String(canvasPicture.Substring(canvasPicture.IndexOf("base64,")+7)); var memoryStream = new System.IO.MemoryStream(picBytes); //create image in order to convert to jpeg var img = Image.FromStream(memoryStream); var ms = new System.IO.MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Person.Picture = ms.ToArray(); ctx.SaveChanges(); TempData["success"] = "Successfully saved person image"; return Search(Id.ToString()); } catch (Exception e) { ModelState.AddModelError("Picture", "Unknown error with image: " + e.Message); } } else { ModelState.AddModelError("Picture", "Select an image to upload"); } return AddImageToPerson(Id, PersonId); }