예제 #1
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Calendar>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    db.Appointments.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ActionResult Edit(Calendar calendar)
        {
            CalendarContext calendarContext = new CalendarContext();

            calendarContext.Entry(calendar).State = System.Data.Entity.EntityState.Modified;
            calendarContext.SaveChanges();
            return(RedirectToAction("Admin"));
        }
예제 #3
0
        public IActionResult Put(Guid rosterId, string code, [FromBody] Shift item)
        {
            if (item == null || item.Code != code || item.RosterId != rosterId)
            {
                return(BadRequest());
            }
            var existing = _context.Shifts.Find(rosterId, code);

            if (existing == null)
            {
                return(NotFound());
            }
            _context.Entry(existing).CurrentValues.SetValues(ServerShift.FromShift(item));
            _context.SaveChanges();
            return(new NoContentResult());
        }
        public IActionResult Put(Guid rosterId, string abbreviation, [FromBody] StaffMember item)
        {
            if (item == null || item.StaffMemberCode != abbreviation || item.RosterId != rosterId)
            {
                return(BadRequest());
            }
            var existing = _context.Staff.Find(rosterId, abbreviation);

            if (existing == null)
            {
                return(NotFound());
            }
            var serverStaffMember = ServerStaffMember.FromStaffMember(item);

            _context.Entry(existing).CurrentValues.SetValues(serverStaffMember);
            _context.SaveChanges();
            return(new NoContentResult());
        }
예제 #5
0
        public async Task <bool> UpdateAsync(T item)
        {
            var dbItem = await GetAsync(item.Id);

            if (dbItem == null)
            {
                return(false);
            }
            //dbItem.Localization = item.Localization;
            //dbItem.Owner = item.Owner;
            //dbItem.StartDate = item.StartDate;
            //dbItem.EndDate = item.EndDate;
            //dbItem.Description = item.Description;
            //dbItem.CalendarType = item.CalendarType;
            db.Entry(dbItem).CurrentValues.SetValues(item);
            // await Task.Run(()=>db.Update(dbItem));
            return(true);
        }
예제 #6
0
        public IActionResult Put(Guid rosterId, [FromBody] Roster item)
        {
            if (item == null || item.Id != rosterId)
            {
                return(BadRequest());
            }
            var existing = _context.Rosters.Find(rosterId);

            if (existing == null)
            {
                return(NotFound());
            }
            var serverRoster = ServerRoster.FromRoster(item);

            _context.Entry(existing).CurrentValues.SetValues(serverRoster);
            _context.SaveChanges();
            return(new NoContentResult());
        }
예제 #7
0
        public ActionResult UpdateCalendarEvent(string id, string title, string description, string location, string start, string end, string allDay)
        {
            // Convert start and end to DateTime objects

            /*
             * DateTime startTime = DateTime.ParseExact(start, "dd-MM-yyyy HH:mm:ss",
             *                         System.Globalization.CultureInfo.InvariantCulture);
             * DateTime endTime = DateTime.ParseExact(end, "dd-MM-yyyy HH:mm:ss",
             *                         System.Globalization.CultureInfo.InvariantCulture);
             */
            int eventID = Convert.ToInt32(id);

            using (CalendarContext db = new CalendarContext())
            {
                // Update CalendarEvent in database
                CalendarEvent calEventToUpdate = db.CalendarEvents.Where(ce => ce.EventID == eventID).FirstOrDefault();

                // Create CalendarEvent to be passed to database
                // Only title, description, and location can be updated currently
                CalendarEvent calEvent = new CalendarEvent
                {
                    EventID     = Convert.ToInt32(id),
                    FBID        = (String)Session["FBID"],
                    Title       = title,
                    Description = description,
                    Location    = location,
                    StartTime   = calEventToUpdate.StartTime,
                    EndTime     = calEventToUpdate.EndTime,
                    Recurring   = false,
                    AllDay      = calEventToUpdate.AllDay
                };

                if (calEventToUpdate != null)
                {
                    db.Entry(calEventToUpdate).CurrentValues.SetValues(calEvent);
                }
                db.SaveChanges();
            }

            return(View());
        }