Example #1
0
        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();
     }
 }
Example #4
0
        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);
        }
Example #7
0
 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));
        }
Example #9
0
        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>());
        }
Example #10
0
        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"));
        }
Example #13
0
        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);
            }
        }
Example #14
0
        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);
            }
        }
Example #15
0
        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);
            }
        }
Example #16
0
        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"));
            }
        }
Example #18
0
        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);
            }
        }
Example #19
0
        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);
        }
Example #20
0
        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));
        }
Example #21
0
        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);
            }
        }
Example #22
0
 public AddSeats(OfficeContext context)
 {
     _context = context;
 }
 public ManagersController(OfficeContext context, IEmployeesRepostiory employeesRepostiory)
 {
     _context             = context;
     _employeesRepostiory = employeesRepostiory;
 }
Example #24
0
 public ManagerController(OfficeContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Example #25
0
        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);
        }
Example #26
0
 public void BuildModel()
 {
     var db = new OfficeContext();
        db.Database.Initialize(true);
      // var clients = db.Clients.ToList();
 }
 public DoctorsController(OfficeContext context)
 {
     _context = context;
 }
Example #28
0
 public TeamEventService(OfficeContext context)
 {
     this.context = context;
 }
Example #29
0
 /// <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;
 }
Example #32
0
 //public HomeController(ILogger<HomeController> logger)
 //{
 //    _logger = logger;
 //}
 /// <summary>
 ///  Организоваваем первоначальные данные для всех моделей
 /// </summary>
 /// <param name="context">Контекст работы с БД</param>
 public HomeController(OfficeContext context)
 {
     db = context;
 }
Example #33
0
 public UserService(OfficeContext context)
 {
     this.context = context;
 }
Example #34
0
 public UsageController(OfficeContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #35
0
        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;
        }