public RedirectResult PostGroupCreate(Entity.GroupModal entity) { Business.GroupModal.InsertGroupModal(entity); //Quer dizer que tem excel para realizer a inserção if (entity.file != null) { //verifica se é por dd ou por idcity //se for por idcity insere o range var datas = new List <int>(); string fileLocation = string.Format("{0}/{1}", Server.MapPath("~/Content/Upload/Excel/GroupModal"), "GroupModal" + "id_" + entity.idGroupModal + DateTime.Now.Day + ".csv"); if (entity.isByCity) { datas = entity.file.GetIdCityByExcel(fileLocation); } else { datas = entity.file.GetIdCityByDddInExcel(fileLocation); } if (datas.Any()) { var entities = datas.Select(s => new Entity.GroupModalCity() { idCity = s, idGroupModal = entity.idGroupModal }).ToList(); Business.GroupModalCities.Insert(entities); } } return(Redirect("~/Grupos/Modal")); }
public ActionResult VincularModal() { var GroupModal = Business.GroupModal.GetAllGroupModal(); Entity.GroupModal groupModal = new Entity.GroupModal { idGroupModal = 0, name = "Selecione" }; GroupModal.Add(groupModal); ViewBag.GroupModals = GroupModal.OrderBy(e => e.idGroupModal); var Pages = Business.Page.GetPages().ToList(); Entity.Page page = new Entity.Page { idPage = 0, name = "Selecione" }; Pages.Add(page); ViewBag.Pages = Pages.OrderBy(e => e.idPage);; var Modals = Business.GroupModal.GetAll(); Entity.Modal modal = new Entity.Modal { idModal = 0, name = "Selecione" }; Modals.Add(modal); ViewBag.Modals = Modals.OrderBy(e => e.idModal);; return(View()); }
public RedirectResult PostAlterarGroupModal(Entity.GroupModal entity) { //Função de Alterar Business.GroupModal.UpdateGroupModal(entity); return(Redirect("~/Grupos/Modal")); }
public static void InsertGroupModal(Entity.GroupModal entity) { entity.dtCreate = DateTime.Now; using (var context = new Entity.OiWeb()) { context.GroupModals.Add(entity); context.SaveChanges(); } }
public static void UpdateGroupModal(Entity.GroupModal data) { using (var context = new Entity.OiWeb()) { var groupModal = context.GroupModals.Find(data.idGroupModal); if (groupModal != null) { groupModal.name = data.name; groupModal.description = data.description; context.GroupModals.Attach(groupModal); var entry = context.Entry(groupModal); entry.Property(e => e.name).IsModified = true; entry.Property(e => e.description).IsModified = true; context.SaveChanges(); } } }