public async Task UpdateAward(Award updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             /*Award awa = await (from a in context.Awards
                                      where a.AwardId == updateData.AwardId
                                      select a).ToListAsync();*/
             Award awa = context.Awards.First(a => a.AwardId == updateData.AwardId);
             context.Entry(awa).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
        public SingleItemResponse<PositionDTO> UpdatePosition(PositionDTO updateData)
        {
            var updateDataFull = new Position()
            {
                PositionId = updateData.PositionId,
                PositionTitle = updateData.PositionTitle,
                Section = updateData.Section,
                Order = updateData.Order,
                EditedBy = GetUserId(),
                EditDate = DateTime.Now
            };

            using (var context = new AF_Context())
            {
                try
                {
                    Position pos = context.Positions.First(p => p.PositionId == updateData.PositionId);
                    context.Entry(pos).CurrentValues.SetValues(updateDataFull);
                    context.SaveChanges();
                    int id = updateData.PositionId;
                    return GetPosition(id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
        public SingleItemResponse<PlayDataDTO> UpdatePlay(PlayDataDTO updateData)
        {
            var updateDataFull = new Play()
            {
                PlayId = updateData.PlayId,
                Title = updateData.Title,
                Author = updateData.Author,
                FestivalId = updateData.FestivalId,
                Day = updateData.Day,
                Order = updateData.Order,
                PlayedBy = updateData.PlayedBy,
                Motto = updateData.Motto,
                EditedBy = GetUserId(),
                EditDate = DateTime.Now
            };

            using (var context = new AF_Context())
            {
                try
                {
                    Play pla = context.Plays.First(p => p.PlayId == updateData.PlayId);
                    context.Entry(pla).CurrentValues.SetValues(updateDataFull);
                    context.SaveChanges();
                    int id = updateData.PlayId;
                    return GetPlay(id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
        public SingleItemResponse<JobDTO> UpdateJob(JobDTO updateData)
        {
            var updateDataFull = new Job()
            {
                JobId = updateData.JobId,
                JobTitle = updateData.JobTitle,
                EditedBy = GetUserId(),
                EditDate = DateTime.Now
            };

            using (var context = new AF_Context())
            {
                try
                {
                    Job jo = context.Jobs.First(j => j.JobId == updateData.JobId);
                    context.Entry(jo).CurrentValues.SetValues(updateDataFull);
                    context.SaveChanges();
                    int id = updateData.JobId;
                    return GetJob(id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
        public SingleItemResponse<FestivalDTO> UpdateFestival(FestivalDTO updateData)
        {
            var updateDataFull = new Festival()
            {
                FestivalId = updateData.FestivalId,
                Year = updateData.Year,
                BeginningDate = updateData.BeginningDate,
                EndDate = updateData.EndDate,
                EditedBy = GetUserId(),
                EditDate = DateTime.Now
            };

            using (var context = new AF_Context())
            {
                try
                {
                    Festival fes = context.Festivals.First(f => f.FestivalId == updateData.FestivalId);
                    context.Entry(fes).CurrentValues.SetValues(updateDataFull);
                    context.SaveChanges();
                    int id = updateData.FestivalId;
                    return GetFestival(id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
        public SingleItemResponse<CategoryDTO> UpdateCategory(CategoryDTO updateData)
        {
            var updateDataFull = new Category
            {
                CategoryId = updateData.CategoryId,
                Title = updateData.Title,
                EditDate = DateTime.Now,
                EditedBy = GetUserId(),
                Group = updateData.Group,
                Order = updateData.Order
            };

            using (var context = new AF_Context())
            {
                try
                {
                    Category cat = context.Categories.First(c => c.CategoryId == updateData.CategoryId);
                    context.Entry(cat).CurrentValues.SetValues(updateDataFull);
                    context.SaveChanges();
                    int id = updateData.CategoryId;
                    return GetCategory(id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
 public async Task UpdatePosition(Position updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             Position pos = context.Positions.First(p => p.PositionId == updateData.PositionId);
             context.Entry(pos).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public async Task UpdateRelationPersonPlayRole(RelationPersonPlayRole updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             RelationPersonPlayRole rel = context.RelationsPersonPlayRole.First(r => r.RelationPersonPlayRoleId == updateData.RelationPersonPlayRoleId);
             context.Entry(rel).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public async Task UpdatePerson(Person updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             Person per = context.People.First(a => a.PersonId == updateData.PersonId);
             context.Entry(per).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public async Task UpdateNews(News updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             News ne = context.News.First(n => n.NewsId == updateData.NewsId);
             context.Entry(ne).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public async Task UpdateJob(Job updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             Job jo = context.Jobs.First(j => j.JobId == updateData.JobId);
             context.Entry(jo).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public async Task UpdateFestival(Festival updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             Festival fes = context.Festivals.First(f => f.FestivalId == updateData.FestivalId);
             context.Entry(fes).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public async Task UpdateUser(User updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             User us = context.Users.First(u => u.UserId == updateData.UserId);
             context.Entry(us).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
        public SingleItemResponse<AwardDataDTO> UpdateAward(AwardDataDTO updateData)
        {
            var updateDataFull = new Award()
            {
                AwardId = updateData.AwardId,
                CategoryId = updateData.CategoryId,
                PlayId = updateData.PlayId,
                EditedBy = GetUserId(),
                EditDate = DateTime.Now
            };

            using (var context = new AF_Context())
            {
                try
                {
                    Award awa = context.Awards.First(a => a.AwardId == updateData.AwardId);
                    context.Entry(awa).CurrentValues.SetValues(updateDataFull);
                    context.SaveChanges();
                    int id = updateData.AwardId;
                    return GetAward(id);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
 public async Task UpdatePlay(Play updateData)
 {
     using (var context = new AF_Context())
     {
         try
         {
             Play pla = context.Plays.First(p => p.PlayId == updateData.PlayId);
             context.Entry(pla).CurrentValues.SetValues(updateData);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public ActionResult Edit([Bind(Include = "FestivalId,Year,BeginningDate,EndDate")] FestivalDTO updateData)
 {
     if (ModelState.IsValid)
     {
         var updateDataFull = new Festival()
         {
             FestivalId = updateData.FestivalId,
             Year = updateData.Year,
             BeginningDate = updateData.BeginningDate,
             EndDate = updateData.EndDate,
             EditedBy = 1,//GetUserId(),
             EditDate = DateTime.Now
         };
         using (var context = new AF_Context())
         {
             Festival fes = context.Festivals.Find(updateData.FestivalId);
             context.Entry(fes).CurrentValues.SetValues(updateDataFull);
             context.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     //ViewBag.EditedBy = new SelectList(db.Users, "UserId", "Login", play.EditedBy);
     //ViewBag.FestivalId = new SelectList(db.Festivals, "FestivalId", "FestivalId", play.FestivalId);
     return View(updateData);
 }
        public ActionResult Edit([Bind(Include = "PlayId,Title,Author,FestivalId,Day,Order,PlayedBy,Motto")] PlayDataDTO updateData)
        {
            if (ModelState.IsValid)
            {
            var updateDataFull = new Play()
            {
                PlayId = updateData.PlayId,
                Title = updateData.Title,
                Author = updateData.Author,
                FestivalId = updateData.FestivalId,
                Day = updateData.Day,
                Order = updateData.Order,
                PlayedBy = updateData.PlayedBy,
                Motto = updateData.Motto,
                EditedBy = 1,
                //EditedBy = GetUserId(),    //???????
                EditDate = DateTime.Now
            };

            using (var context = new AF_Context())
            {
                    Play pla = context.Plays.Find(updateData.PlayId);// First(p => p.PlayId == updateData.PlayId);
                    string return_s = "Details/" + pla.FestivalId;
                    context.Entry(pla).CurrentValues.SetValues(updateDataFull); //check for substituding only edited
                    //context.Entry(updateDataFull).State = EntityState.Modified;
                    context.SaveChanges();
                    //int id = updateData.PlayId;
                    //return Redirect(Request.UrlReferrer.ToString()); //RedirectToAction("Index")
                    //return RedirectToAction(return_s);
                    return RedirectToAction(return_s, "Festival");
                }
            }
            //ViewBag.EditedBy = new SelectList(db.Users, "UserId", "Login", festival.EditedBy);
            return View(updateData);
        }