Пример #1
0
 public ActionResult Edit(Block block, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "Block", new { blockId = block.BlockId }));
     }
     if (!ModelState.IsValid)
     {
         this.ViewData[Defines.FieldsTypesEnum.NoMarks.ToString()] = Utils.GetFields(Defines.FieldsTypesEnum.NoMarks, DB);
         this.ViewData["Groups"] = Utils.GetGroupList(DB);
         return(View(block));
     }
     if (button == "preview")
     {
         var query = DB.Blocks.Where(i => i.BlockId == block.BlockId).ToList();
         if (query.Count > 0)
         {
             block = query.First();
         }
         return(View("Preview", Utils.GetBlockHtmlBody(block, DB)));
     }
     DB.Entry(block).State = System.Data.EntityState.Modified;
     TempData["Message"]   = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Add);
     if (button == "part" && TempData["Message"] as String == String.Empty)
     {
         return(RedirectToAction("Add", "Part", new { blockId = block.BlockId }));
     }
     return(RedirectToAction("Index"));
 }
Пример #2
0
 public ActionResult Edit(Field field, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "Field", new { fieldId = field.FieldId }));
     }
     if (!ModelState.IsValid)
     {
         return(View(field));
     }
     DB.Entry(field).State = System.Data.EntityState.Modified;
     TempData["Message"]   = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(Category category, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "Category", new { categoryId = category.CategoryId }));
     }
     if (!ModelState.IsValid)
     {
         return(View(category));
     }
     DB.Entry(category).State = System.Data.EntityState.Modified;
     TempData["Message"]      = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
Пример #4
0
 public ActionResult Edit(Group group, string button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "Group", new { groupId = group.GroupId }));
     }
     if (!ModelState.IsValid)
     {
         return(View(group));
     }
     DB.Entry(group).State = System.Data.EntityState.Modified;
     TempData["Message"]   = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(WebResource webResource, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "WebResource", new { webResourceId = webResource.WebResourceId }));
     }
     if (!ModelState.IsValid)
     {
         return(View(webResource));
     }
     DB.Entry(webResource).State = System.Data.EntityState.Modified;
     TempData["Message"]         = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(TextStyle textStyle, string button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "TextStyle", new { textStyleId = textStyle.TextStyleId }));
     }
     if (!ModelState.IsValid)
     {
         return(View(textStyle));
     }
     DB.Entry(textStyle).State = System.Data.EntityState.Modified;
     TempData["Message"]       = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(SubCategory subCategory, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "SubCategory", new { subCategoryId = subCategory.SubCategoryId }));
     }
     if (!ModelState.IsValid)
     {
         this.ViewData["Categories"] = Utils.GetCategoryList(DB);
         return(View(subCategory));
     }
     DB.Entry(subCategory).State = System.Data.EntityState.Modified;
     TempData["Message"]         = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(Lawsuit lawsuit, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "Lawsuit", new { lawsuitId = lawsuit.LawsuitId }));
     }
     if (!ModelState.IsValid)
     {
         this.ViewData["SubCategories"] = DB.SubCategories.ToList();
         this.ViewData["WebResources"]  = Utils.GetCustomWebResourseList(DB, true);
         return(View(lawsuit));
     }
     DB.Entry(lawsuit).State = System.Data.EntityState.Modified;
     TempData["Message"]     = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Index"));
 }
Пример #9
0
 public ActionResult Edit(Part part, String button)
 {
     if (button == "remove")
     {
         return(RedirectToAction("Remove", "Part", new { partId = part.PartId }));
     }
     if (!ModelState.IsValid)
     {
         this.ViewData[Defines.FieldsTypesEnum.NoMarks.ToString()]   = Utils.GetFields(Defines.FieldsTypesEnum.NoMarks, DB);
         this.ViewData[Defines.FieldsTypesEnum.WithMarks.ToString()] = Utils.GetFields(Defines.FieldsTypesEnum.WithMarks, DB);
         this.ViewData["TextStyles"] = Utils.GetTextStylesList(DB);
         return(View(part));
     }
     if (button == "preview")
     {
         return(View("Preview", Utils.GetPartHtmlBody(part, DB)));
     }
     DB.Entry(part).State = System.Data.EntityState.Modified;
     TempData["Message"]  = Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
     return(RedirectToAction("Edit", "Block", new { blockId = part.BlockId }));
 }
 public void Action(LawsuitBlockData data)
 {
     if (data.Type == LawsuitBlockData.Types.Add)
     {
         LawsuitBlock pair = new LawsuitBlock();
         pair.LawsuitId = data.LawsuitId;
         pair.BlockId   = data.BlockId;
         if (DB.LawsuitBlocks.Where(i => i.LawsuitId == pair.LawsuitId).ToList().Count > 0)
         {
             pair.LawsuitBlockWeight = DB.LawsuitBlocks.Where(i => i.LawsuitId == pair.LawsuitId).Select(i => i.LawsuitBlockWeight).Max() + 1;
         }
         else
         {
             pair.LawsuitBlockWeight = 0;
         }
         DB.LawsuitBlocks.Add(pair);
         Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Add);
     }
     else if (data.Type == LawsuitBlockData.Types.ChangeWeight)
     {
         int                 lawsuitId    = data.LawsuitId;
         int                 source       = data.BlockId;
         int                 target       = data.TargetBlockId;
         LawsuitBlock        sourceItem   = null;
         int                 targetWeight = 0;
         List <LawsuitBlock> list         = DB.LawsuitBlocks.Select(i => i).Where(i => i.LawsuitId == lawsuitId).ToList();
         list.Sort(Utils.BlockComparer);
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].BlockId == target)
             {
                 targetWeight = list[i].LawsuitBlockWeight;
                 while (list[i].BlockId != source)
                 {
                     list[i].LawsuitBlockWeight = ++(list[i].LawsuitBlockWeight);
                     DB.Entry(list[i]).State    = EntityState.Modified;
                     i++;
                 }
                 list[i].LawsuitBlockWeight = targetWeight;
                 DB.Entry(list[i]).State    = EntityState.Modified;
                 Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
                 return;
             }
             if (list[i].BlockId == source)
             {
                 sourceItem = list[i];
                 i++;
                 while (list[i].BlockId != target)
                 {
                     list[i].LawsuitBlockWeight = --(list[i].LawsuitBlockWeight);
                     DB.Entry(list[i]).State    = EntityState.Modified;
                     i++;
                 }
                 sourceItem.LawsuitBlockWeight = list[i].LawsuitBlockWeight;
                 DB.Entry(sourceItem).State    = EntityState.Modified;
                 list[i].LawsuitBlockWeight    = --(list[i].LawsuitBlockWeight);
                 DB.Entry(list[i]).State       = EntityState.Modified;
                 Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Edit);
                 return;
             }
         }
     }
     else
     {
         LawsuitBlock pair = DB.LawsuitBlocks.Select(i => i).Where(i => i.BlockId == data.BlockId && i.LawsuitId == data.LawsuitId).First();
         DB.LawsuitBlocks.Remove(pair);
         Utils.TrySaveChanges(DB, Defines.SaveChangesCases.Remove);
     }
 }