Ejemplo n.º 1
0
        public ActionResult GetServices()
        {
            var allAnunciosList = new List<AN_Anuncios>();
            List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>();
            using (Entities model = new Entities())
            {
                allAnunciosList = model.AN_Anuncios.AsParallel().OrderByDescending(c => c.AN_Fecha).Where(sts => sts.ST_Id == 1).ToList();

                foreach (var item in allAnunciosList)
                {
                    string username = item.UserProfile.Name;
                    string statusDesc = item.ST_Estatus.ST_Descripcion;
                    var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion;
                    var firstImage = string.Empty;
                    if (item.AE_AnunciosExtras.FirstOrDefault() != null)
                    {
                        firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl;
                    }
                    else
                    {
                        firstImage = item.UserProfile.Image == null ? "~/Images/No_Profile.jpg" : item.UserProfile.Image;
                    }

                    //item.AN_Fecha = Convert.ToDateTime(item.AN_Fecha.ToShortDateString());

                    var getRating = model.SEL_ValoracionAnuncios(item.AN_Id).FirstOrDefault();

                    string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");
                    var formatted = firstImage.Replace("~", "");
                    if (formatted.StartsWith("/"))
                        formatted = formatted.Remove(0, 1);
                    firstImage = urlimg + formatted;

                    var number = 0;
                    item.SS_SolicitudServicio.AsParallel().ToList().ForEach((counter) =>
                    {
                        number += counter.RW_Reviews.Count;
                    });
                    viewModelAnuncios.Add(new AnunciosViewModel
                    {
                        Usuario = username,
                        EstatusDescription = statusDesc,
                        AnunciosInfo = item,
                        CategoriaDescripcion = categoria,
                        FirstImage = firstImage,
                        Rating = getRating,
                        Comments = number,
                    });

                }
            }
            if (viewModelAnuncios == null || viewModelAnuncios.Count == 0)
            {
                return HttpNotFound();
            }

            var anuncios = viewModelAnuncios.SerializeToJson();
            return Json(anuncios);
        }
 public ActionResult ChangeStatus(int Solicitud, int Status)
 {
     Updating update = new Updating() { Message = "Proceso de Actualización Exitosa." };
     using (var db = new Entities())
     {
         var solicitud = db.SS_SolicitudServicio.Find(Solicitud);
         solicitud.ST_Id = Status;
         db.Entry(solicitud).State = EntityState.Modified;
         db.SaveChanges();
         if (Status == 3)
         {
             SendEmailNotification(solicitud, true);
         }
     }
     return Json(update.SerializeToJson(), JsonRequestBehavior.AllowGet);
 }
        public ActionResult GetInformationAnuncios(FormCollection form)
        {
            var allAnunciosList = new List<AN_Anuncios>();

            var category = string.IsNullOrEmpty(form["Categoria"]) ? default(int) : int.Parse(form["Categoria"].ToString());
            var subcategoria = string.IsNullOrEmpty(form["SubCategoria"]) ? default(int) : int.Parse(form["SubCategoria"].ToString());
            var lugar = string.IsNullOrEmpty(form["Lugar"]) ? default(string) : form["Lugar"].ToString();
            var descripcion = string.IsNullOrEmpty(form["Descripcion"]) ? default(string) : form["Descripcion"].ToString();

            List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>();
            using (Entities model = new Entities())
            {

                allAnunciosList = db.Get_AdvanceSearch(category, subcategoria, descripcion, lugar).ToList();

                foreach (var item in allAnunciosList)
                {
                    string username = item.UserProfile.Name;
                    string statusDesc = item.ST_Estatus.ST_Descripcion;
                    var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion;
                    var firstImage = string.Empty;
                    if (item.AE_AnunciosExtras.FirstOrDefault() != null)
                    {
                        firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl;
                    }
                    else
                    {
                        firstImage = item.UserProfile.Image == null ? "~/Images/No_Profile.jpg" : item.UserProfile.Image;
                    }

                    var getRating = model.SEL_ValoracionAnuncios(item.AN_Id).FirstOrDefault();
                    string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");
                    var formatted = firstImage.Replace("~", "");
                    if (formatted.StartsWith("/"))
                        formatted = formatted.Remove(0, 1);
                    firstImage = urlimg + formatted;

                    List<RW_Reviews> rvList = new List<RW_Reviews>();
                    model.SS_SolicitudServicio.Where(c => c.AN_Id == item.AN_Id).AsParallel().ToList().ForEach(
                        c =>
                        {
                            c.RW_Reviews.AsParallel().ToList().ForEach(i => rvList.Add(i));
                        });

                    viewModelAnuncios.Add(new AnunciosViewModel
                    {
                        Usuario = username,
                        EstatusDescription = statusDesc,
                        AnunciosInfo = item,
                        CategoriaDescripcion = categoria,
                        FirstImage = firstImage,
                        Rating = getRating,
                        ReviewList = rvList
                    });

                }
            }
            if (viewModelAnuncios == null || viewModelAnuncios.Count == 0)
            {
                return Json(new { Error = "No se encontraron registros" });
            }
            var anuncios = viewModelAnuncios.SerializeToJson();
            return Json(anuncios);
        }
        public ActionResult GetAnunciosByUser()
        {
            int UserId = UserId = WebSecurity.CurrentUserId;
            var allAnunciosList = new List<AN_Anuncios>();
            List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>();
            using (Entities model = new Entities())
            {
                allAnunciosList = model.AN_Anuncios.OrderBy(c => c.AN_Fecha).Where(acc => acc.ST_Id == 1 && acc.UserId == UserId).ToList();

                var categoriasList = new List<Categoria>();
                db.CD_CategoriaServicio.ToList().ForEach(c =>
                {
                    var subCatList = new List<SubCategorias>();

                    c.SBS_SubCategoriaServicio.ToList().ForEach(sb =>
                    {
                        subCatList.Add(new SubCategorias { SubCatId = sb.SBS_Id, SubCatDesc = sb.SBS_Descripcion });
                    });
                    categoriasList.Add(new Categoria
                    {
                        CatId = c.CD_Id,
                        CatDesc = c.CD_Descripcion,
                        SubCatCollection = subCatList
                    });
                });

                ViewBag.Categories = categoriasList;

                foreach (var item in allAnunciosList)
                {
                    string username = item.UserProfile.Name;
                    string statusDesc = item.ST_Estatus.ST_Descripcion;
                    var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion;
                    var firstImage = string.Empty;
                    if (item.AE_AnunciosExtras.FirstOrDefault() != null)
                    {
                        firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl;
                    }

                    var getRating = model.SEL_ValoracionAnuncios(item.AN_Id).FirstOrDefault();

                    string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");
                    var formatted = firstImage.Replace("~", "");
                    if (formatted.StartsWith("/"))
                        formatted = formatted.Remove(0, 1);
                    firstImage = urlimg + formatted;

                    viewModelAnuncios.Add(new AnunciosViewModel
                    {
                        Usuario = username,
                        EstatusDescription = statusDesc,
                        AnunciosInfo = item,
                        CategoriaDescripcion = categoria,
                        FirstImage = firstImage, Rating = getRating
                    });

                }
            }
            if (viewModelAnuncios == null || viewModelAnuncios.Count == 0)
            {
                return HttpNotFound();
            }
            return View(viewModelAnuncios);
        }
        private void SendEmailNotification(SS_SolicitudServicio solicitud, bool isReview)
        {
            string pXml = string.Empty;
            var ppEmailTemplate = new Notification();
            var userName = WebSecurity.CurrentUserName;
            using (db = new Entities())
            {
                var soli = db.SS_SolicitudServicio.Where(c => c.SS_Id == solicitud.SS_Id);
                ppEmailTemplate.CustomerName = soli.FirstOrDefault().UserProfile.Name;
                ppEmailTemplate.ProviderName = soli.FirstOrDefault().AN_Anuncios.UserProfile.Name;
                ppEmailTemplate.SolicitudId = soli.FirstOrDefault().SS_Id;
                ppEmailTemplate.AnuncioId = soli.FirstOrDefault().AN_Anuncios.AN_Id;
                ppEmailTemplate.EmailCliente = soli.FirstOrDefault().UserProfile.UserName;
                ppEmailTemplate.EmailProveedor = soli.FirstOrDefault().AN_Anuncios.UserProfile.UserName;

                string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");
                var firstImage = "~/Images/logo2-blue.png";
                var formatted = firstImage.Replace("~", "");
                if (formatted.StartsWith("/"))
                    formatted = formatted.Remove(0, 1);
                firstImage = urlimg + formatted;

                ppEmailTemplate.Image = firstImage;

                string link = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/") + "Review/Create/" + solicitud.SS_Id;
                ppEmailTemplate.LinkReview = link;

                pXml = ppEmailTemplate.Serialize<Notification>();
                string serverPath = string.Empty;
                serverPath = base.Server.MapPath("~");
                string body = string.Empty;

                if (isReview)
                {
                    body = pXml.ConvertXML(Path.Combine(serverPath, @"EmailTemplates\ServicioReview.xslt"));
                    Extensions.ExtensionHelper.SendEmail(ppEmailTemplate.EmailCliente, "Informanos de como te fue en el servicio", body);

                    var soliupdate = db.SS_SolicitudServicio.Find(solicitud.SS_Id);
                    soliupdate.ST_Id = 4;
                    db.Entry(soliupdate).State = EntityState.Modified;
                    db.SaveChanges();

                }

                else
                {
                    body = pXml.ConvertXML(Path.Combine(serverPath, @"EmailTemplates\ServicioRequestClient.xslt"));
                    Extensions.ExtensionHelper.SendEmail(ppEmailTemplate.EmailCliente, "Solicitud de Servicio", body);

                    body = pXml.ConvertXML(Path.Combine(serverPath, @"EmailTemplates\ServicioRequestProved.xslt"));
                    Extensions.ExtensionHelper.SendEmail(ppEmailTemplate.EmailProveedor, "Solicitud de Servicio", body);
                }
            }
        }
 public ActionResult TakeService(FormCollection form)
 {
     if (form[0] != null)
     {
         int anuncioId = int.Parse(form[0]);
         using (var db = new Entities())
         {
             var solicitud = db.SS_SolicitudServicio.Add(new SS_SolicitudServicio
             {
                 AN_Id = anuncioId,
                 ST_Id = 1,
                 SS_Fecha = System.DateTime.Now,
                 UserId = WebSecurity.CurrentUserId
             });
             var solicitudcreada = db.SaveChanges<SS_SolicitudServicio>(solicitud);
             if (solicitudcreada != null)
             {
                 SendEmailNotification(solicitudcreada, false);
             }
         }
     }
     return null;
 }
 public ActionResult SolicitudRequest()
 {
     var mysol = new List<SolicitudViewModel>();
     using (var db = new Entities())
     {
         var solicitudes = db.SS_SolicitudServicio.Where(c => c.AN_Anuncios.UserId == WebSecurity.CurrentUserId);
         Func<int, string> x = value =>
         {
             switch (value)
             {
                 case 1: return "Activo";
                 case 2: return "Cancelado";
                 case 3: return "Realizado";
                 case 4: return "En espera de Review";
                 case 5: return "Completado";
                 case 6: return "Iniciar Tarea";
                 case 7: return "A revisión";
                 default: return "";
             }
         };
         solicitudes.ToList().ForEach((sol) =>
         {
             mysol.Add(new SolicitudViewModel
             {
                 Solicitante = sol.UserProfile.Name,
                 EmailSolicitante = sol.UserProfile.UserName,
                 FechaCreacion = sol.SS_Fecha,
                 Solicitud = sol.SS_Id,
                 Status = x.Invoke(sol.ST_Id),
                 TelefonoSolicitante = "No Telefono",
                 StatusId = sol.ST_Id
             });
         });
     }
     return View(mysol);
 }
Ejemplo n.º 8
0
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            using (var db = new Entities())
            {
                var ListCategorias = db.CD_CategoriaServicio.ToList();
                var firstCategoria = ListCategorias.FirstOrDefault().CD_Id;
                var ListSubCategory = db.SBS_SubCategoriaServicio.Where(c => c.CD_Id == firstCategoria).ToList();

                ViewBag.Categories = new SelectList(ListCategorias, "CD_Id", "CD_Descripcion");
                ViewBag.SubCategories = new SelectList(ListSubCategory, "SBS_Id", "SBS_Descripcion");
            }

            return View();
        }
        public ActionResult ForgotPassword(string Email)
        {
            //check user existance
            var user = Membership.GetUser(Email);
            if (user == null)
            {
                if (Email == string.Empty)
                    TempData["Message"] = "No ha ingresado el correo electrónico.";
                else
                    TempData["Message"] = "El correo electronico ingresado no corresponde a un usuario existente.";
            }
            else
            {
                //generate password token
                var token = WebSecurity.GeneratePasswordResetToken(Email);
                //create url with above token
                var resetLink = Url.Action("ResetPassword", "Account", new { un = Email, rt = token }, "http");

                //get user emailid
                Entities db = new Entities();
                var emailid = (from i in db.UserProfile
                               where i.UserName == Email
                               select i.UserName).FirstOrDefault();
                //send mail
                string subject = "Restaurar su contraseña de Service Market";
                string body = MensajeRestablecerPassword(resetLink, Email); //edit it
                try
                {
                    SendEMail(emailid, subject, body);
                    TempData["Message"] = "Mensaje enviado.";
                }
                catch (Exception ex)
                {
                    TempData["Message"] = "Ha ocurrido un error enviando el mensaje." + ex.Message;
                }
                //only for testing
                TempData["Message"] = "Se ha enviado un correo electrónico en el cual podrá restaurar su contraseña.";

            }

            return View();
        }
Ejemplo n.º 10
0
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (Entities db = new Entities())
                {
                    UserProfile user = db.UserProfile.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table

                        db.UserProfile.Add(new UserProfile { UserName = model.UserName, ST_Id = 1, MP_MemberShipId = 1, Name = model.UserName });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return RedirectToLocal(returnUrl, string.Empty);
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "Ya existe una cuenta con esta cuenta de correo. Por favor ingrese un correo diferente.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     using (var db = new Entities())
     {
         int solicitud = int.Parse(filterContext.ActionParameters.Values.FirstOrDefault().ToString());
         if (db.RW_Reviews.Any(c => c.SS_Id == solicitud))
         {
             filterContext.Result = new RedirectResult("~/Review/ReviewSubmitted");
             return;
         }
         var soli = db.SS_SolicitudServicio.FirstOrDefault(c => c.SS_Id == solicitud && c.ST_Id == 4);
         if (soli == null)
         {
             filterContext.Result = new RedirectResult("~/Review/NoReviewAllowed");
             return;
         }
         if (soli.UserId != WebSecurity.CurrentUserId)
         {
             filterContext.Result = new RedirectResult("~/Review/NoReviewAllowed");
             return;
         }
     }
 }
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer<Entities>(null);

                try
                {
                    using (var context = new Entities())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    if (!WebSecurity.Initialized)
                    {
                        WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                    }
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
Ejemplo n.º 13
0
        public ActionResult GetCompanyInfo()
        {
            var Company = new COM_Compañia();

            using (Entities model = new Entities())
            {
                Company = model.COM_Compañia.FirstOrDefault();
            }

            if (Company == null)
            {
                return HttpNotFound();
            }

            return Json(Company.SerializeToJson());
        }
        // Delete file from the server
        private void DeleteFile(HttpContext context)
        {
            if (context.Request["id"] != null)
            {
                using (var db = new Entities())
                {
                    var extra = db.AE_AnunciosExtras.Find(int.Parse(context.Request["id"].ToString()));
                    var currentPath = ExtraRoot + extra.AN_Id + @"\" + extra.AN_Nombre;
                    if (File.Exists(currentPath))
                    {
                        File.Delete(currentPath);
                    }
                    db.AE_AnunciosExtras.Remove(extra);
                    db.SaveChanges();

                }
            }
            else
            {
                var filePath = System.Web.HttpContext.Current.Server.MapPath(context.Request["f"]);
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
        }
        private void SaveContent(List<FilesStatus> files)
        {
            using (var tran = new TransactionScope())
            {
                using (var db = new Entities())
                {
                    files.ForEach(c =>
                    {
                        var anun = new AE_AnunciosExtras();
                        anun.AN_Id = int.Parse(HttpContext.Current.Session["Anuncio"].ToString());
                        anun.AN_ImagenUrl = c.UrlPath;
                        anun.AN_Nombre = Path.GetFileName(c.UrlPath);
                        var entity =db.SaveChanges<AE_AnunciosExtras>(anun);
                        c.IdResource = entity.AE_Id;
                    });

                }
                tran.Complete();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult GetLastAnuncios()
        {
            var allAnunciosList = new List<AN_Anuncios>();
            List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>();
            using (Entities model = new Entities())
            {
                allAnunciosList = model.AN_Anuncios.OrderByDescending(day => day.AN_Fecha).Where(acc => acc.ST_Id == 1).Take(3).ToList();

                foreach (var item in allAnunciosList)
                {
                    string username = item.UserProfile.Name;
                    string statusDesc = item.ST_Estatus.ST_Descripcion;
                    var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion;
                    var firstImage = string.Empty;
                    if (item.AE_AnunciosExtras.FirstOrDefault() != null)
                    {
                        firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl;
                    }
                    else
                    {
                        firstImage = item.UserProfile.Image == null ? "~/Images/No_Profile.jpg" : item.UserProfile.Image;
                    }

                    string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");
                    var formatted = firstImage.Replace("~", "");
                    if (formatted.StartsWith("/"))
                        formatted = formatted.Remove(0, 1);
                    firstImage = urlimg + formatted;

                    string descripcion = string.Empty;
                    descripcion = item.AN_Descripcion.Substring(0, item.AN_Descripcion.Length < 112 ? item.AN_Descripcion.Length : 112);
                    if (descripcion.LastIndexOf(' ') > 0)
                        descripcion = descripcion.Substring(0, descripcion.LastIndexOf(' '));

                    descripcion += "...";

                    item.AN_Descripcion = descripcion;

                    viewModelAnuncios.Add(new AnunciosViewModel
                    {
                        Usuario = username,
                        EstatusDescription = statusDesc,
                        AnunciosInfo = item,
                        CategoriaDescripcion = categoria,
                        FirstImage = firstImage
                    });

                }
            }
            if (viewModelAnuncios == null || viewModelAnuncios.Count == 0)
            {
                return HttpNotFound();
            }
            return Json((viewModelAnuncios).SerializeToJson());
        }
        public ActionResult Index()
        {
            var allAnunciosList = new List<AN_Anuncios>();
            List<AnunciosViewModel> viewModelAnuncios = new List<AnunciosViewModel>();
            using (Entities model = new Entities())
            {
                allAnunciosList = model.AN_Anuncios.OrderBy(c => c.AN_Fecha).ToList();
                foreach (var item in allAnunciosList)
                {
                    string username = item.UserProfile.Name;
                    string statusDesc = item.ST_Estatus.ST_Descripcion;
                    var categoria = item.SBS_SubCategoriaServicio.CD_CategoriaServicio.CD_Descripcion;
                    var firstImage = string.Empty;
                    if (item.AE_AnunciosExtras.FirstOrDefault() != null)
                    {
                        firstImage = item.AE_AnunciosExtras.FirstOrDefault().AN_ImagenUrl;
                    }

                    string urlimg = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");
                    var formatted = firstImage.Replace("~", "");
                    if (formatted.StartsWith("/"))
                        formatted = formatted.Remove(0, 1);
                    firstImage = urlimg + formatted;

                    viewModelAnuncios.Add(new AnunciosViewModel
                    {
                        Usuario = username,
                        EstatusDescription = statusDesc,
                        AnunciosInfo = item,
                        CategoriaDescripcion = categoria,
                        FirstImage = firstImage
                    });

                }
            }
            if (viewModelAnuncios == null || viewModelAnuncios.Count == 0)
            {
                return HttpNotFound();
            }
            return View(viewModelAnuncios);
        }
Ejemplo n.º 18
0
        public ActionResult ResetPassword(string un, string rt)
        {
            Entities db = new Entities();
            //TODO: Check the un and rt matching and then perform following
            //get userid of received username
            var userid = (from i in db.UserProfile
                          where i.UserName == un
                          select i.UserId).FirstOrDefault();
            //check userid and token matches
            bool any = (from j in db.webpages_Membership
                        where (j.UserId == userid)
                        && (j.PasswordVerificationToken == rt)
                        //&& (j.PasswordVerificationTokenExpirationDate < DateTime.Now)
                        select j).Any();

            if (any == true)
            {
                //generate random password
                string newpassword = GenerateRandomPassword(6);
                //reset password
                bool response = WebSecurity.ResetPassword(rt, newpassword);
                if (response == true)
                {
                    //get user emailid to send password
                    var emailid = (from i in db.UserProfile
                                   where i.UserName == un
                                   select i.UserName).FirstOrDefault();
                    //send email
                    string subject = "Nueva Contraseña de Service Market";
                    string body = MensajeNuevoPassword(newpassword); //edit it
                    try
                    {
                        SendEMail(emailid, subject, body);
                        TempData["Message"] = "Correo enviado.";
                    }
                    catch (Exception ex)
                    {
                        TempData["Message"] = "Ha ocurrido un error al intentar enviar el correo." + ex.Message;
                    }

                    //display message
                    TempData["Message"] = "Hemos atendido su solicitud de restauración de contraseña. Su nueva contraseña para Service Market es: " + newpassword + " De igual forma le hemos enviado un correo con su nueva contraseña.";
                }
                else
                {
                    TempData["Message"] = "Hubo un error al reiniciar la contraseña, por favor vuelva a intentarlo más a tarde o comuníquese con nuestros agnetes de Service Market.";
                }
            }
            else
            {
                TempData["Message"] = "Hubo un error al reiniciar la contraseña, por favor vuelva a intentarlo más a tarde o comuníquese con nuestros agnetes de Service Market";
            }

            return View("ResetPasswordComplete");
        }