public HomeController(ILogger <HomeController> logger, IOptions <DBOptions> dbOtions) { var connString = dbOtions.Value.ConnString; officeContext = new OfficeContext(connString); _logger = logger; }
//[Ignore] public void BuildModel() { var db = new OfficeContext(); db.Database.Initialize(true); // var clients = db.Clients.ToList(); }
private static void ResetDatabase() { using (var db = new OfficeContext()) { db.Database.EnsureDeleted(); db.Database.EnsureCreated(); } }
public ActionResult Index(PagingParams args, FilterBarMode? Mode, bool? ShowStatusBar) { IList<Conference> conferences = null; using (var context = new OfficeContext()) { conferences = context.Conferences.ToList(); } return conferences.GridJSONActions<Conference>(); }
public IEnumerable <Employee> Get() //restituisce la lista di employees { using var _ctx = new OfficeContext(); var result = _ctx.Employees //.Include(t=>t.Notes) .ToList(); return(result); }
public IEnumerable <Office> Get(string name) //restituisce la lista di employees di un ufficio { using var _ctx = new OfficeContext(); var result = _ctx.Offices .Include(e => e.Employees) .ToList(); return(result); }
public ActionResult JSONAdd(Conference conference) { IList<Conference> conferences = null; using (var context = new OfficeContext()) { context.Conferences.Add(conference); context.SaveChanges(); conferences = context.Conferences.ToList(); } return conferences.GridJSONActions<Conference>(); }
public IActionResult Get(int id) //restiuisce l'impiegato in base all'id { using var _ctx = new OfficeContext(); var employee = _ctx.Employees.SingleOrDefault(e => e.Id == id); if (employee == null) { return(NotFound()); } return(Ok(employee)); }
public ActionResult Index(PagingParams args, FilterBarMode?Mode, bool?ShowStatusBar) { IList <Conference> conferences = null; using (var context = new OfficeContext()) { conferences = context.Conferences.ToList(); } return(conferences.GridJSONActions <Conference>()); }
public ActionResult JSONAdd(Conference conference) { IList <Conference> conferences = null; using (var context = new OfficeContext()) { context.Conferences.Add(conference); context.SaveChanges(); conferences = context.Conferences.ToList(); } return(conferences.GridJSONActions <Conference>()); }
public IActionResult Post(Employee employee) //<= model Binding //inseriemnto di un nuovo employee { using var _ctx = new OfficeContext(); if (employee != null) { _ctx.Employees.Add(employee); _ctx.SaveChanges(); return(Ok()); } return(BadRequest("Invalid employee")); }
public IActionResult Put(int id, Employee employee) //modifica di un employee { using var _ctx = new OfficeContext(); if (employee != null && id == employee.Id) { _ctx.Employees.Update(employee); _ctx.SaveChanges(); return(Ok()); } return(BadRequest("Error updating Employee")); }
public void AddNewOffice_ThrowsException_WhenStreetNameIsNull() { using (var oc = new OfficeContext()) { var office = new Office { StreetNumber = 78, StreetName = null, City = "Lille", ZipCode = 59800 }; oc.CreateOffice(office); } }
public void AddNewOffice_ThrowsException_WhenCityIsEmpty() { using (var oc = new OfficeContext()) { var office = new Office { StreetNumber = 78, StreetName = "rue Saint André", City = "", ZipCode = 59800 }; oc.CreateOffice(office); } }
public void AddNewOffice_ThrowsException_WhenZipCodeIsEmpty() { using (var oc = new OfficeContext()) { var office = new Office { StreetNumber = 74, StreetName = "rue Saint André", City = "Lille" //zip_code = , }; oc.CreateOffice(office); } }
public void AddNewOffice_ThrowsException_WhenStreetNumberIsEmpty() { using (var oc = new OfficeContext()) { var office = new Office { StreetNumber = Convert.ToInt32(null), StreetName = "rue Saint André", City = "Lille", ZipCode = 59800 }; oc.CreateOffice(office); } }
public IActionResult Delete(int id) //cancella in base all'id { using var _ctx = new OfficeContext(); var employee = _ctx.Employees.SingleOrDefault(e => e.Id == id); if (employee != null) { _ctx.Employees.Remove(employee); _ctx.SaveChanges(); return(Ok()); } else { return(BadRequest("Cannot delete Employee")); } }
public void AddNewOffice_OfficeIsStoredInDataStore() { using (var oc = new OfficeContext()) { var office = new Office { StreetNumber = 74, StreetName = "rue Saint André", City = "Lille", ZipCode = 59800 }; oc.CreateOffice(office); var exists = oc.DataContext.Offices.Any(c => c.Id == office.Id); Assert.IsTrue(exists); } }
public ActionResult Schedule(SchedulePropertiesModel model) { ViewData["ScheduleModel"] = model; var queryString = Request.QueryString; DatePickerModel dtPicker = new DatePickerModel(); dtPicker.ChangeMonth = true; dtPicker.ChangeYear = true; dtPicker.AutoFormat = ((Skins)model.Skins); ViewData["DatePickerModel"] = dtPicker; Session["ParentID"] = queryString["parentID"]; Session["ScheduleType"] = queryString["scheduleType"]; IList<Seminar> seminars; var parentId = Guid.Parse(queryString["parentID"]); var scheduleType = int.Parse(queryString["scheduleType"]); using (var context = new OfficeContext()) { seminars = context.Seminars.Where(s => s.ParentID == parentId && s.ScheduleType == (ScheduleType)scheduleType).ToList(); } return View(seminars); }
public ActionResult Schedule(SchedulePropertiesModel model) { ViewData["ScheduleModel"] = model; var queryString = Request.QueryString; DatePickerModel dtPicker = new DatePickerModel(); dtPicker.ChangeMonth = true; dtPicker.ChangeYear = true; dtPicker.AutoFormat = ((Skins)model.Skins); ViewData["DatePickerModel"] = dtPicker; Session["ParentID"] = queryString["parentID"]; Session["ScheduleType"] = queryString["scheduleType"]; IList <Seminar> seminars; var parentId = Guid.Parse(queryString["parentID"]); var scheduleType = int.Parse(queryString["scheduleType"]); using (var context = new OfficeContext()) { seminars = context.Seminars.Where(s => s.ParentID == parentId && s.ScheduleType == (ScheduleType)scheduleType).ToList(); } return(View(seminars)); }
public void UpdateOffice_AppliedValuesAreStoredInDataStore() { using (var oc = new OfficeContext()) { var office = new Office { StreetNumber = 74, StreetName = "rue Saint André", City = "Lille", ZipCode = 59800 }; oc.CreateOffice(office); const int newStreetNumber = 12, newZipCode = 59700; const string newStreetName = "avenue de la République", newCity = "Marcq-en-Baroeul"; office.StreetNumber = newStreetNumber; office.StreetName = newStreetName; office.City = newCity; office.ZipCode = newZipCode; // Act oc.UpdateOffice(office); // Assert oc.DataContext.Entry(office).Reload(); Assert.AreEqual(newStreetNumber, office.StreetNumber); Assert.AreEqual(newZipCode, office.ZipCode); Assert.AreEqual(newStreetName, office.StreetName); Assert.AreEqual(newCity, office.City); } }
public AddSeats(OfficeContext context) { _context = context; }
public ManagersController(OfficeContext context, IEmployeesRepostiory employeesRepostiory) { _context = context; _employeesRepostiory = employeesRepostiory; }
public ManagerController(OfficeContext context, IMapper mapper) { this.context = context; this.mapper = mapper; }
public ActionResult Schedule(Params args, Schedule scheduleObject) { scheduleObject.SetCurrentCultureInfo(); ActionResult result = null; var parentID = Guid.Parse(Session["ParentID"].ToString()); var scheduleType = (ScheduleType)int.Parse(Session["ScheduleType"].ToString()); using (var context = new OfficeContext()) { if (args.CurrentAction == "Save") { var startTime = DateTime.Parse(args.StartTime.Replace("上午", "AM").Replace("下午", "PM")); var endTime = DateTime.Parse(args.EndTime.Replace("上午", "AM").Replace("下午", "PM")); Seminar appoint = new Seminar() { StartTime = startTime, EndTime = endTime, Subject = args.Subject, Location = args.Location, Description = args.Description, Owner = args.Owner, Priority = args.Priority, Recurrence = args.Recurrence, RecurrenceType = args.RecurrenceType, RecurrenceCount = Convert.ToInt16(args.RecurrenceTypeCount), Reminder = args.Reminder, Categorize = args.Categorize, AllDay = args.AllDay, RecurrenceEndDate = args.RecurrenceEnd != null?Convert.ToDateTime(args.RecurrenceEnd) : endTime, RecurrenceStartDate = args.RecurrenceStart != null?Convert.ToDateTime(args.RecurrenceStart) : startTime, RecurrenceRule = args.RecurrenceRules, ParentID = parentID, ScheduleType = scheduleType, CurrentUser = User.Identity.Name }; context.Seminars.Add(appoint); context.SaveChanges(); } else if (args.CurrentAction == "EditOccurrence") { //SeminarRepository.EditOccurrence(args); } else if (args.CurrentAction == "Edit") { var appid = int.Parse(args.AppID); var point = context.Seminars.Single(s => s.Id == appid); var startTime = DateTime.Parse(args.StartTime.Replace("上午", "AM").Replace("下午", "PM")); var endTime = DateTime.Parse(args.EndTime.Replace("上午", "AM").Replace("下午", "PM")); point.StartTime = startTime; point.EndTime = endTime; point.Subject = args.Subject; point.Location = args.Location; point.Description = args.Description; point.Owner = args.Owner; point.Priority = args.Priority; point.Recurrence = args.Recurrence; point.RecurrenceType = args.RecurrenceType; point.RecurrenceCount = Convert.ToInt16(args.RecurrenceTypeCount); point.Reminder = args.Reminder; point.Categorize = args.Categorize; point.AllDay = args.AllDay; point.RecurrenceEndDate = args.RecurrenceEnd != null?Convert.ToDateTime(args.RecurrenceEnd) : endTime; point.RecurrenceStartDate = args.RecurrenceStart != null?Convert.ToDateTime(args.RecurrenceStart) : startTime; point.RecurrenceRule = args.RecurrenceRules; point.ParentID = parentID; point.ScheduleType = scheduleType; point.CurrentUser = User.Identity.Name; //context.Seminars.Add(point); context.SaveChanges(); } else if (args.CurrentAction == "Delete") { var appid = int.Parse(args.AppID); var point = context.Seminars.Single(s => s.Id == appid); context.Seminars.Remove(point); context.SaveChanges(); } else if (args.CurrentAction == "DismissAll" || args.CurrentAction == "Dismiss" || args.CurrentAction == "Snooze") { //SeminarRepository.ReminderAction(args); } result = context.Seminars.Where(s => s.ParentID == parentID && s.ScheduleType == (ScheduleType)scheduleType).ToList().ScheduleActions <ScheduleHtmlActionResult>(); } return(result); }
public void BuildModel() { var db = new OfficeContext(); db.Database.Initialize(true); // var clients = db.Clients.ToList(); }
public DoctorsController(OfficeContext context) { _context = context; }
public TeamEventService(OfficeContext context) { this.context = context; }
/// <inheritdoc /> public OfficeController(OfficeContext context, IMapper mapper) : base(context, mapper) { _mapper = mapper; }
public InvitationService(OfficeContext context) { this.context = context; }
public DoctorsController(OfficeContext db) { _db = db; }
//public HomeController(ILogger<HomeController> logger) //{ // _logger = logger; //} /// <summary> /// Организоваваем первоначальные данные для всех моделей /// </summary> /// <param name="context">Контекст работы с БД</param> public HomeController(OfficeContext context) { db = context; }
public UserService(OfficeContext context) { this.context = context; }
public UsageController(OfficeContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public ActionResult Schedule(Params args, Schedule scheduleObject) { scheduleObject.SetCurrentCultureInfo(); ActionResult result = null; var parentID = Guid.Parse(Session["ParentID"].ToString()); var scheduleType = (ScheduleType)int.Parse(Session["ScheduleType"].ToString()); using (var context = new OfficeContext()) { if (args.CurrentAction == "Save") { var startTime = DateTime.Parse(args.StartTime.Replace("上午", "AM").Replace("下午", "PM")); var endTime = DateTime.Parse(args.EndTime.Replace("上午", "AM").Replace("下午", "PM")); Seminar appoint = new Seminar() { StartTime = startTime, EndTime = endTime, Subject = args.Subject, Location = args.Location, Description = args.Description, Owner = args.Owner, Priority = args.Priority, Recurrence = args.Recurrence, RecurrenceType = args.RecurrenceType, RecurrenceCount = Convert.ToInt16(args.RecurrenceTypeCount), Reminder = args.Reminder, Categorize = args.Categorize, AllDay = args.AllDay, RecurrenceEndDate = args.RecurrenceEnd != null ? Convert.ToDateTime(args.RecurrenceEnd) : endTime, RecurrenceStartDate = args.RecurrenceStart != null ? Convert.ToDateTime(args.RecurrenceStart) : startTime, RecurrenceRule = args.RecurrenceRules, ParentID = parentID, ScheduleType = scheduleType, CurrentUser = User.Identity.Name }; context.Seminars.Add(appoint); context.SaveChanges(); } else if (args.CurrentAction == "EditOccurrence") { //SeminarRepository.EditOccurrence(args); } else if (args.CurrentAction == "Edit") { var appid = int.Parse(args.AppID); var point = context.Seminars.Single(s => s.Id == appid); var startTime = DateTime.Parse(args.StartTime.Replace("上午", "AM").Replace("下午", "PM")); var endTime = DateTime.Parse(args.EndTime.Replace("上午", "AM").Replace("下午", "PM")); point.StartTime = startTime; point.EndTime = endTime; point.Subject = args.Subject; point.Location = args.Location; point.Description = args.Description; point.Owner = args.Owner; point.Priority = args.Priority; point.Recurrence = args.Recurrence; point.RecurrenceType = args.RecurrenceType; point.RecurrenceCount = Convert.ToInt16(args.RecurrenceTypeCount); point.Reminder = args.Reminder; point.Categorize = args.Categorize; point.AllDay = args.AllDay; point.RecurrenceEndDate = args.RecurrenceEnd != null ? Convert.ToDateTime(args.RecurrenceEnd) : endTime; point.RecurrenceStartDate = args.RecurrenceStart != null ? Convert.ToDateTime(args.RecurrenceStart) : startTime; point.RecurrenceRule = args.RecurrenceRules; point.ParentID = parentID; point.ScheduleType = scheduleType; point.CurrentUser = User.Identity.Name; //context.Seminars.Add(point); context.SaveChanges(); } else if (args.CurrentAction == "Delete") { var appid = int.Parse(args.AppID); var point = context.Seminars.Single(s => s.Id == appid); context.Seminars.Remove(point); context.SaveChanges(); } else if (args.CurrentAction == "DismissAll" || args.CurrentAction == "Dismiss" || args.CurrentAction == "Snooze") { //SeminarRepository.ReminderAction(args); } result = context.Seminars.Where(s => s.ParentID == parentID && s.ScheduleType == (ScheduleType)scheduleType).ToList().ScheduleActions<ScheduleHtmlActionResult>(); } return result; }