public ActionResult PubList() { List <PublicacionMec> pubs; try { // Ger user data var userId = User.Identity.GetUserId(); var user = UC.GetUser(userId); if (user == null) { return(Error_FailedRequest()); } // Conseguir todas las publicaciones porque obvio no hay filtro de user por API :tired_af: pubs = PC.GetAllPub(string.Empty, string.Empty, string.Empty, string.Empty).ToList(); if (pubs == null) { return(Error_FailedRequest()); } // Filtrar para las publicaciones de Mecánicos pubs = pubs.Where(x => x.appuser_id.Equals(userId)).ToList(); } catch (Exception e) { ErrorWriter.ExceptionError(e); return(Error_CustomError(e.Message)); } return(View(pubs)); }
public ActionResult Profile() { var userId = User.Identity.GetUserId(); if (userId == null) { return(Error_FailedRequest()); } Usuario usuario; try { usuario = UC.GetUser(userId); if (usuario == null) { return(Error_FailedRequest()); } var userTypeLst = UC.GetAllTypes().ToList(); if (userTypeLst == null) { return(Error_FailedRequest()); } var userStatusLst = UC.GetAllStatus().ToList(); if (userStatusLst == null) { return(Error_FailedRequest()); } usuario = UC.ProcessUser(usuario, userTypeLst, userStatusLst); } catch (Exception e) { ErrorWriter.ExceptionError(e); return(Error_CustomError(e.Message)); } return(View(usuario)); }
public ActionResult ServDetails(string servId) { if (string.IsNullOrEmpty(servId)) { return(Error_InvalidUrl()); } Servicio serv; BookingVM bookTemplate; List <BookingRestVM> bookRestList; try { serv = SC.GetServ(servId); if (serv == null) { return(Error_FailedRequest()); } var userId = User.Identity.GetUserId(); if (!string.IsNullOrEmpty(userId)) { var user = UC.GetUser(userId); if (user == null) { return(Error_FailedRequest()); } bookRestList = BC.GetAllBookRest(servId).ToList(); if (bookRestList == null) { return(Error_FailedRequest()); } bookRestList = bookRestList.Where(x => x.start_date_hour > DateTime.Now).ToList(); var otherBookList = BC.GetAllBookings("ACT", serv_id: servId); if (otherBookList == null) { return(Error_FailedRequest()); } otherBookList = otherBookList.Where(x => x.start_date_hour > DateTime.Now).ToList(); var dateStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day + 1, 10, 0, 0); bookTemplate = new BookingVM() { booking_id = Guid.NewGuid().ToString().Replace("-", "").ToUpper(), serv_id = serv.serv_id, appuser_id = userId, status_booking_id = "ACT", updated_at = default, // Update on post
public ActionResult PubDetails(string pubId) { if (string.IsNullOrEmpty(pubId)) { return(Error_InvalidUrl()); } PublicacionMec pub; Usuario user; try { pub = PMC.GetPub(pubId); if (pub == null) { return(Error_FailedRequest()); } var userId = User.Identity.GetUserId(); if (!string.IsNullOrEmpty(userId)) { user = UC.GetUser(userId); if (user == null) { return(Error_FailedRequest()); } ViewBag.User = user; var updateRes = PMC.AddToPubViews(pubId); if (!updateRes) { return(Error_FailedRequest()); } } } catch (Exception e) { ErrorWriter.ExceptionError(e); return(Error_CustomError(e.Message)); } return(View(pub)); }