示例#1
0
 public ActionResult reservarFacilidad(long idFacilidad, string dateFaci,
                                       string fechaDisponible)
 {
     try
     {
         long     userId   = (long)Session["USER_ID"];
         TimeSpan masU     = TimeSpan.FromHours(1);
         efac     facility = entities.efacs.Find(idFacilidad);
         book     newBook  = new book();
         newBook.first_name = facility.first_name;
         int      horaSelectd = Convert.ToInt32(fechaDisponible);
         TimeSpan start_time  = TimeSpan.FromHours(horaSelectd);
         TimeSpan end_time    = TimeSpan.FromHours(horaSelectd);
         newBook.start_time           = start_time;
         newBook.end_time             = end_time.Add(masU);
         newBook.status               = 1;
         newBook.requested_date       = DateTime.ParseExact(dateFaci, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
         newBook.description          = facility.description;
         newBook.cost_per_reservation = facility.cost_reservation;
         newBook.id_efac              = idFacilidad;
         newBook.created_at           = DateTime.Now;
         newBook.community_id         = facility.community_id;
         newBook.idUser               = userId;
         entities.books.Add(newBook);
         entities.SaveChanges();
         return(Redirect(Url.Action("reservas", "facilidades")));
     }
     catch (Exception ex)
     {
         return(Redirect(Url.Action("reservar", "facilidades", new { Error = "Problema interno " + ex.Message })));
     }
 }
        public ActionResult editfac(long facID, string first_name, string description,
                                    string start_time, string end_time, int duration, string cost_reservation,
                                    HttpPostedFileBase upload_regulation)
        {
            try
            {
                efac editFac = entities.efacs.Find(facID);
                editFac.first_name  = first_name;
                editFac.description = description;
                int      start  = Convert.ToInt32(start_time);
                int      end    = Convert.ToInt32(end_time);
                TimeSpan Inicio = TimeSpan.FromHours(start);
                TimeSpan Final  = TimeSpan.FromHours(end);
                TimeSpan min    = new TimeSpan(8, 0, 0);
                TimeSpan max    = new TimeSpan(21, 0, 0);
                if (Inicio < min || Final > max)
                {
                    return(Redirect(Url.Action("editar", "facilidades", new { area = "coadmin", facID = facID, Error = "La hora de inicio y de fin no estan entre las permitidas..." })));
                }
                else if (Final < Inicio)
                {
                    return(Redirect(Url.Action("editar", "facilidades", new { area = "coadmin", facID = facID, Error = "La hora de fin no puede ser menor a la hora de inicio..." })));
                }
                else
                {
                    editFac.start_time       = Inicio;
                    editFac.end_time         = Final;
                    editFac.duration         = duration;
                    editFac.cost_reservation = Convert.ToDecimal(cost_reservation);
                    if (upload_regulation != null && upload_regulation.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(upload_regulation.FileName);
                        if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload")))
                        {
                            Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload"));
                        }

                        if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "Regulation")))
                        {
                            Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Regulation"));
                        }
                        var path = Path.Combine(Server.MapPath("~/Upload/Regulation"), fileName);
                        upload_regulation.SaveAs(path);
                        editFac.upload_regulation = fileName;
                    }
                    entities.SaveChanges();
                    return(Redirect(Url.Action("disponibles", "facilidades", new { area = "coadmin" })));
                }
            }
            catch (Exception ex)
            {
                return(Redirect(Url.Action("editar", "facilidades", new { area = "coadmin", facID = facID, Error = "Error al editar la facilidad: ", ex.Message })));
            }
        }
示例#3
0
 public JsonResult DeleteFac(long delID)
 {
     try
     {
         efac delFac = entities.efacs.Find(delID);
         entities.efacs.Remove(delFac);
         entities.SaveChanges();
         return(Json(new { result = "success" }));
     }
     catch (Exception ex)
     {
         return(Json(new { result = "error", exception = ex.HResult }));
     }
 }
示例#4
0
        public ActionResult newfac(string first_name, string description,
                                   string start_time, string end_time, int duration,
                                   string cost_reservation, HttpPostedFileBase upload_regulation)
        {
            try
            {
                efac newFac = new efac();
                newFac.first_name  = first_name;
                newFac.description = description;
                newFac.start_time  = TimeSpan.ParseExact(start_time, "h\\:mm",
                                                         System.Globalization.CultureInfo.CurrentCulture, TimeSpanStyles.None
                                                         );
                newFac.end_time = TimeSpan.ParseExact(end_time, "h\\:mm",
                                                      System.Globalization.CultureInfo.CurrentCulture, TimeSpanStyles.None
                                                      );
                newFac.cost_reservation = Convert.ToDecimal(cost_reservation);
                newFac.duration         = duration;
                newFac.created_at       = DateTime.Now;
                newFac.community_id     = Convert.ToInt64(Session["CURRENT_COMU"]);
                if (upload_regulation != null && upload_regulation.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(upload_regulation.FileName);
                    if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload")))
                    {
                        Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload"));
                    }

                    if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "Regulation")))
                    {
                        Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Regulation"));
                    }
                    var path = Path.Combine(Server.MapPath("~/Upload/Regulation"), fileName);
                    upload_regulation.SaveAs(path);
                    newFac.upload_regulation = fileName;
                }
                entities.efacs.Add(newFac);
                entities.SaveChanges();
                return(Redirect(Url.Action("disponibles", "facilidades", new { area = "webmaster" })));
            }
            catch (Exception ex)
            {
                return(Redirect(Url.Action("agregar", "facilidades",
                                           new {
                    area = "webmaster",
                    exception = ex.Message
                })));
            }
        }
示例#5
0
        public ActionResult editar(long?facID)
        {
            if (Session["USER_ID"] != null)
            {
                if (facID != null)
                {
                    long userId  = (long)Session["USER_ID"];
                    user curUser = entities.users.Find(userId);
                    List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                    efac editFac = entities.efacs.Find(facID);
                    editarFacViewModel viewModel = new editarFacViewModel();
                    viewModel.side_menu     = "facilidades";
                    viewModel.side_sub_menu = "facilidades_editar";

                    viewModel.editFac = editFac;
                    int[] timeList = new int[24];
                    for (int i = 1; i < 25; i++)
                    {
                        timeList.SetValue(i, i - 1);
                    }
                    viewModel.timeList       = timeList;
                    viewModel.curUser        = curUser;
                    viewModel.pubTaskList    = ep.GetNotifiTaskList(userId);
                    viewModel.pubMessageList = pubMessageList;
                    viewModel.messageCount   = ep.GetUnreadMessageCount(pubMessageList);
                    return(View(viewModel));
                }
                else
                {
                    return(Redirect(Url.Action("NotFound", "Error")));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
示例#6
0
        public ActionResult reservar(long?id)
        {
            if (Session["USER_ID"] != null)
            {
                if (Session["CURRENT_COMU"] != null)
                {
                    if (id != null)
                    {
                        efac facilidad = entities.efacs.Find(id);
                        if (facilidad != null)
                        {
                            try{
                                long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                                long userId       = (long)Session["USER_ID"];
                                user curUser      = entities.users.Find(userId);
                                List <ShowMessage>   pubMessageList = ep.GetChatMessages(userId);
                                facilidadesViewModel viewModel      = new facilidadesViewModel();
                                string        inicio     = Convert.ToString(facilidad.start_time);
                                string        final      = Convert.ToString(facilidad.end_time);
                                TimeSpan      horaInicio = TimeSpan.Parse(inicio);
                                TimeSpan      horaFin    = TimeSpan.Parse(final);
                                TimeSpan      masU       = TimeSpan.FromHours(1);
                                List <string> timeList   = new List <string>();
                                while (horaInicio < horaFin)
                                {
                                    timeList.Add(
                                        horaInicio.ToString("hh':'mm") + " - " +
                                        horaInicio.Add(masU).ToString("hh':'mm"));

                                    horaInicio = horaInicio.Add(masU);
                                }
                                titulosList                      = ep.GetTitulosByTitular(userId);
                                listComunities                   = ep.GetCommunityListByTitular(titulosList);
                                viewModel.communityList          = listComunities;
                                viewModel.timeList               = timeList;
                                viewModel.facilidadSe            = facilidad;
                                viewModel.side_menu              = "reservar";
                                viewModel.side_sub_menu          = "facilidades_reservar";
                                viewModel.curUser                = curUser;
                                viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                                viewModel.pubTaskList            = ep.GetNotifiTaskList(userId);
                                viewModel.pubMessageList         = pubMessageList;
                                viewModel.messageCount           = ep.GetUnreadMessageCount(pubMessageList);
                                viewModel.communityName          = ep.GetCommunityCoInfo(userId)[0];
                                viewModel.communityApart         = ep.GetCommunityCoInfo(userId)[1];
                                return(View(viewModel));
                            }
                            catch (Exception ex)
                            {
                                return(Redirect(Url.Action("error", "control", new { Error = "Reservar facilidad: ", ex.Message })));
                            }
                        }
                        else
                        {
                            return(Redirect(Url.Action("disponibles", "facilidades", new { Error = "No existe la facilidad" })));
                        }
                    }
                    else
                    {
                        return(Redirect(Url.Action("disponibles", "facilidades")));
                    }
                }
                else
                {
                    return(Redirect(Url.Action("disponibles", "facilidades", new { Error = "No permitido. Usted no pertence a ninguna comunidad" })));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
        //public ActionResult reservar()
        //{
        //    if (Session["USER_ID"] != null)
        //    {
        //        if (Session["CURRENT_COMU"] != null)
        //        {
        //            try
        //            {
        //                long userId = (long)Session["USER_ID"];
        //                user curUser = entities.users.Find(userId);
        //                List<ShowMessage> pubMessageList = ep.GetChatMessages(userId);
        //                facilidadesViewModel viewModel = new facilidadesViewModel();

        //                communityList = ep.GetCommunityList(userId);
        //                viewModel.communityList = communityList;

        //                viewModel.side_menu = "facilidades";
        //                viewModel.side_sub_menu = "facilidades_reservar";
        //                 viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
        //                viewModel.curUser = curUser;
        //                viewModel.pubTaskList = ep.GetNotifiTaskList(userId);
        //                viewModel.pubMessageList = pubMessageList;
        //                viewModel.messageCount = ep.GetUnreadMessageCount(pubMessageList);
        //                return View(viewModel);
        //            }
        //            catch (Exception ex)
        //            {
        //                return Redirect(Url.Action("error", "control", new { area = "coadmin", Error = "Reservar facilidad: " + ex.Message }));
        //            }
        //        }
        //        else
        //        {
        //            return Redirect(Url.Action("disponibles", "facilidades", new { area = "coadmin", Error = "No puede reservar facilidades. Usted no administra ninguna comunidad. Comuníquese con el Webmaster..." }));
        //        }

        //    } else
        //    {
        //        return Redirect(ep.GetLogoutUrl());
        //    }

        //}

        public ActionResult editar(string Error, long?facID)
        {
            if (Session["USER_ID"] != null)
            {
                if (Session["CURRENT_COMU"] != null)
                {
                    if (facID != null)
                    {
                        long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                        efac editFac      = entities.efacs.Where(x => x.id == facID && x.community_id == communityAct).FirstOrDefault();
                        if (editFac != null)
                        {
                            try
                            {
                                long userId  = (long)Session["USER_ID"];
                                user curUser = entities.users.Find(userId);
                                List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                                editarFacViewModel viewModel      = new editarFacViewModel();
                                communityList                    = ep.GetCommunityList(userId);
                                viewModel.communityList          = communityList;
                                viewModel.side_menu              = "facilidades";
                                viewModel.side_sub_menu          = "facilidades_editar";
                                viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                                viewModel.editFac                = editFac;
                                int[] timeList = new int[24];
                                for (int i = 1; i < 25; i++)
                                {
                                    timeList.SetValue(i, i - 1);
                                }

                                TimeSpan minInicio = new TimeSpan(8, 0, 0);
                                TimeSpan maxInicio = new TimeSpan(21, 0, 0);
                                TimeSpan minFinal  = new TimeSpan(9, 0, 0);
                                TimeSpan maxFinal  = new TimeSpan(22, 0, 0);
                                TimeSpan masU      = TimeSpan.FromHours(1);

                                List <string> timeListIni = new List <string>();
                                List <string> timeListFin = new List <string>();
                                while (minInicio < maxInicio)
                                {
                                    timeListIni.Add(
                                        minInicio.ToString("hh':'mm"));

                                    minInicio = minInicio.Add(masU);
                                }

                                while (minFinal < maxFinal)
                                {
                                    timeListFin.Add(
                                        minFinal.ToString("hh':'mm"));

                                    minFinal = minFinal.Add(masU);
                                }

                                string   ini        = Convert.ToString(editFac.start_time);
                                string   fin        = Convert.ToString(editFac.end_time);
                                TimeSpan horaInicio = TimeSpan.Parse(ini);
                                TimeSpan horaFin    = TimeSpan.Parse(fin);

                                viewModel.inicioEfac     = horaInicio.ToString("hh':'mm");
                                viewModel.finalEfac      = horaFin.ToString("hh':'mm");
                                viewModel.timeListIni    = timeListIni;
                                viewModel.timeListFin    = timeListFin;
                                viewModel.timeList       = timeList;
                                viewModel.curUser        = curUser;
                                viewModel.pubTaskList    = ep.GetNotifiTaskList(userId);
                                viewModel.pubMessageList = pubMessageList;
                                viewModel.messageCount   = ep.GetUnreadMessageCount(pubMessageList);
                                ViewBag.msgError         = Error;
                                return(View(viewModel));
                            }
                            catch (Exception ex)
                            {
                                return(Redirect(Url.Action("error", "control", new { area = "coadmin", Error = "Editar facilidad: " + ex.Message })));
                            }
                        }
                        else
                        {
                            return(Redirect(Url.Action("disponibles", "facilidades", new { area = "coadmin", Error = "No existe ese elemento" })));
                        }
                    }
                    else
                    {
                        return(Redirect(Url.Action("disponibles", "facilidades", new { area = "coadmin" })));
                    }
                }
                else
                {
                    return(Redirect(Url.Action("disponibles", "facilidades", new { area = "coadmin", Error = "No puede editar facilidades. Usted no administra ninguna comunidad. Comuníquese con el Webmaster..." })));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
        public ActionResult newfac(string first_name, string description,
                                   string start_time, string end_time, int duration,
                                   string cost_reservation, HttpPostedFileBase upload_regulation)
        {
            try
            {
                efac newFac = new efac();
                newFac.first_name  = first_name;
                newFac.description = description;
                int      start  = Convert.ToInt32(start_time);
                int      end    = Convert.ToInt32(end_time);
                TimeSpan Inicio = TimeSpan.FromHours(start);
                TimeSpan Final  = TimeSpan.FromHours(end);
                TimeSpan min    = new TimeSpan(8, 0, 0);
                TimeSpan max    = new TimeSpan(21, 0, 0);
                if (Inicio < min || Final > max)
                {
                    return(Redirect(Url.Action("agregar", "facilidades", new { area = "coadmin", Error = "La hora de inicio y de fin no estan entre las permitidas..." })));
                }
                else if (Final < Inicio)
                {
                    return(Redirect(Url.Action("agregar", "facilidades", new { area = "coadmin", Error = "La hora de fin no puede ser menor a la hora de inicio..." })));
                }
                else
                {
                    newFac.start_time       = Inicio;
                    newFac.end_time         = Final;
                    newFac.cost_reservation = Convert.ToDecimal(cost_reservation);
                    newFac.duration         = duration;
                    newFac.created_at       = DateTime.Now;
                    newFac.community_id     = Convert.ToInt64(Session["CURRENT_COMU"]);
                    newFac.status           = 1;
                    if (upload_regulation != null && upload_regulation.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(upload_regulation.FileName);
                        if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload")))
                        {
                            Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload"));
                        }

                        if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "Regulation")))
                        {
                            Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Regulation"));
                        }
                        var path = Path.Combine(Server.MapPath("~/Upload/Regulation"), fileName);
                        upload_regulation.SaveAs(path);
                        newFac.upload_regulation = fileName;
                    }
                    else
                    {
                        return(Redirect(Url.Action("agregar", "facilidades", new { area = "coadmin", Error = "Debe cargar el reglamento" })));
                    }
                    entities.efacs.Add(newFac);
                    entities.SaveChanges();
                    return(Redirect(Url.Action("disponibles", "facilidades", new { area = "coadmin" })));
                }
            }
            catch (Exception ex)
            {
                return(Redirect(Url.Action("agregar", "facilidades",
                                           new {
                    area = "coadmin",
                    exception = ex.Message
                })));
            }
        }