public ActionResult DeleteConfirmed(int id)
        {
            Lista_spotkan lista_spotkan = db.Lista_spotkan.Find(id);

            db.Lista_spotkan.Remove(lista_spotkan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,id_funkcyjna,id_klient,id_spotkanie,status")] Lista_spotkan lista_spotkan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lista_spotkan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_spotkanie = new SelectList(db.Spotkanie, "Id", "opis", lista_spotkan.id_spotkanie);
     ViewBag.id_funkcyjna = new SelectList(db.Uzytkownik, "Id", "imie", lista_spotkan.id_funkcyjna);
     ViewBag.id_klient    = new SelectList(db.Uzytkownik, "Id", "imie", lista_spotkan.id_klient);
     return(View(lista_spotkan));
 }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lista_spotkan lista_spotkan = db.Lista_spotkan.Find(id);

            if (lista_spotkan == null)
            {
                return(HttpNotFound());
            }
            return(View(lista_spotkan));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lista_spotkan lista_spotkan = db.Lista_spotkan.Find(id);

            if (lista_spotkan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_spotkanie = new SelectList(db.Spotkanie, "Id", "opis", lista_spotkan.id_spotkanie);
            ViewBag.id_funkcyjna = new SelectList(db.Uzytkownik, "Id", "imie", lista_spotkan.id_funkcyjna);
            ViewBag.id_klient    = new SelectList(db.Uzytkownik, "Id", "imie", lista_spotkan.id_klient);
            return(View(lista_spotkan));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            // actionVa
            try
            {
                var changedEvent = (Spotkanie)DHXEventsHelper.Bind(typeof(Spotkanie), actionValues);

                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    var status = actionValues["status"].ToString();
                    changedEvent.color = changeColor(status);
                    db.Spotkanie.Add(changedEvent);
                    db.SaveChanges();
                    int           idlast = db.Spotkanie.Max(s => s.Id);
                    Lista_spotkan l      = new Lista_spotkan();
                    l.id_spotkanie = idlast;
                    if (rolaUser() != "administrator")
                    {
                        var        u = db.AspNetUsers.SingleOrDefault(x => x.Email == User.Identity.Name);
                        Uzytkownik p = db.Uzytkownik.SingleOrDefault(k => k.id_aspUser == u.Id);
                        l.id_funkcyjna = p.Id;
                    }
                    else
                    {
                        l.id_funkcyjna = idl;
                    }
                    l.status = status;
                    db.Lista_spotkan.Add(l);
                    db.SaveChanges();

                    break;

                case DataActionTypes.Delete:

                    var instance = db.Spotkanie.FirstOrDefault(o => o.Id == id);
                    var deletedL = db.Lista_spotkan.FirstOrDefault(m => m.id_spotkanie == instance.Id);

                    if (instance != null)
                    {
                        db.Entry(deletedL).State = EntityState.Deleted;
                        db.SaveChanges();
                        db.Entry(changedEvent).State = EntityState.Deleted;
                        db.SaveChanges();
                    }
                    else
                    {
                        action.Type = DataActionTypes.Error;
                    }
                    break;

                default:
                    var statusE = actionValues["status"].ToString();
                    changedEvent.color           = changeColor(statusE);
                    db.Entry(changedEvent).State = EntityState.Modified;
                    db.SaveChanges();

                    var editL = db.Lista_spotkan.FirstOrDefault(m => m.id_spotkanie == id);
                    //if (id != getUser().Id) editL.id_klient = getUser().Id;
                    editL.status          = statusE;
                    db.Entry(editL).State = EntityState.Modified;
                    db.SaveChanges();

                    break;
                }
                //data.SubmitChanges();
                action.TargetId = changedEvent.Id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }



            return(new AjaxSaveResponse(action));
        }