Ejemplo n.º 1
0
 public ActionResult EditCredentials(EditCredentialsDTO request)
 {
     if (ModelState.IsValid)
     {
         if (request.CurrentPassword != request.NewPassword)
         {
             if (BinaryComparer.AreEqual(Account.Password, SHA512Hasher.Hash(request.CurrentPassword)))
             {
                 PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
                 Uri        requestUrl = Request.Url;
                 string     baseUrl    = new UriBuilder(requestUrl.Scheme, requestUrl.Host, requestUrl.Port).ToString();
                 partnerBLL.ChangePasswordEmailSubject  = LocalizationProvider["ChangePasswordEmailSubject"];
                 partnerBLL.ChangePasswordEmailTemplate = LocalizationProvider["ChangePasswordEmailTemplate"];
                 partnerBLL.ChangePassword(Account, request.NewPassword, baseUrl);
                 TempData["Result"] = "PasswordHasBeenChanged";
                 return(RedirectToAction("MyProfile"));
             }
             else
             {
                 AddError("CurrentPassword", "CurrentPasswordDoesntMatch");
                 return(View());
             }
         }
         else
         {
             AddError("NewPassword", "NewAndCurrentPasswordAreTheSame");
             return(View());
         }
     }
     else
     {
         return(BadRequestWithErrors());
     }
 }
Ejemplo n.º 2
0
        public ActionResult AnswerQuestion(Guid id, AnswerQuestionDTO request)
        {
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector)
                {
                    AnswerQuestionEmailSubject  = LocalizationProvider["AnswerQuestionEmailSubject"],
                    AnswerQuestionEmailTemplate = LocalizationProvider["AnswerQuestionEmailTemplate"]
                };
                string baseUrl = new UriBuilder(Request.Url.Scheme, Request.Url.Host, Request.Url.Port).ToString();
                PartnerBLL.AnswerQuestionResult result = partnerBLL.AnswerQuestion(Account, id, request.Answer, baseUrl);
                switch (result)
                {
                case PartnerBLL.AnswerQuestionResult.OK:
                    TempData["Result"] = "QuestionHasBeenAnswered";
                    return(RedirectToAction("ViewCustomerQuestion"));

                case PartnerBLL.AnswerQuestionResult.NotFound: return(HttpNotFound());

                case PartnerBLL.AnswerQuestionResult.QuestionHasBeenAlreadyAnswered:
                default:
                    return(BadRequest());
                }
            }
            else
            {
                bool result = AnswerQuestion_Base(id);
                return(result ? BadRequestWithErrors() as ActionResult : HttpNotFound());
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sAccount = CYRequest.GetString("account");
            string sPId     = CYRequest.GetString("agentid");
            string sign     = CYRequest.GetString("sign");
            int    pid      = 0;

            int.TryParse(sPId, out pid);
            if (pid == 1)
            {
                string        sTicket = PartnerBLL.PartnerKeySel(pid);
                StringBuilder sbText  = new StringBuilder(50);
                sbText.Append(sAccount);
                sbText.Append(sPId);
                sbText.Append(sTicket);
                string sValSign = ProvideCommon.MD5(sbText.ToString());//md5(account + agentid  +  TICKEY_PAY)
                if (sign != sValSign)
                {
                    Response.Redirect("http://www.682.com/Home/xsk");
                }
                else
                {
                    string sPartnerAbbre = PartnerBLL.PartnerAbbreSel(pid);
                    string sAccountC     = string.Format("{0}:{1}", sPartnerAbbre, sAccount);
                    int    iUserID       = PartnerUserBLL.PartnerUserIDSel(sAccount, pid);
                    string sPageUrl      = Request.Url.ToString();
                    LoginStateSet(sAccountC, iUserID, sPageUrl);
                }
            }
            else if (!(LoginSessionVal() || isLoginCookie()))
            {
                Response.Redirect("http://www.682.com/Home/xsk");
            }
        }
Ejemplo n.º 4
0
        public ActionResult DeleteProperty(Guid id)
        {
            PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);

            if (Request.HttpMethod == "GET")
            {
                PropertyDTO property = partnerBLL.ReadPropertyById(Account, id);
                if (property != null && (!property.HasBeenPaid || (property.HasBeenReviewed && !property.HasBeenPublished)))
                {
                    return(View(property));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            else
            {
                PartnerBLL.DeletePropertyResult result = partnerBLL.DeleteProperty(Account, id);
                switch (result)
                {
                case PartnerBLL.DeletePropertyResult.OK:
                    TempData["Result"] = "PropertyHasBeenDeleted";
                    return(RedirectToAction("Properties"));

                case PartnerBLL.DeletePropertyResult.NotFound: return(HttpNotFound());

                default: return(BadRequest());
                }
            }
        }
Ejemplo n.º 5
0
        public ActionResult EditProperty(Guid id, PropertyDTO property)
        {
            Connector connector = WebApp.Connector;

            AddEditProperty_BasePost(connector, property);
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(connector);
                PartnerBLL.UpdatePropertyResult result = partnerBLL.UpdateProperty(Account, id, property);
                switch (result)
                {
                case PartnerBLL.UpdatePropertyResult.OK:
                    TempData["Result"] = "PropertyHasBeenEdited";
                    return(RedirectToAction("ViewProperty", new { id }));

                case PartnerBLL.UpdatePropertyResult.NotFound: return(HttpNotFound());

                default: return(BadRequest());
                }
            }
            else
            {
                AddEditProperty_BaseGet(connector);
                return(BadRequestWithErrors(property));
            }
        }
Ejemplo n.º 6
0
        public ActionResult EditPersonalInfo(PartnerPersonalInfoDTO personalInfo)
        {
            Connector connector = WebApp.Connector;

            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(connector)
                {
                    EmailAddressVerificationSubject  = LocalizationProvider["EmailVerificationSubject"],
                    EmailAddressVerificationTemplate = LocalizationProvider["EmailVerificationTemplate"]
                };
                string baseUrl = new UriBuilder(Request.Url.Scheme, Request.Url.Host, Request.Url.Port).ToString();
                PartnerBLL.UpdatePersonalInfoResult result = partnerBLL.UpdatePersonalInfo(Account.Id, personalInfo, baseUrl, Url.Action("VerifyEmailAddress", "Accounts"));
                switch (result)
                {
                case PartnerBLL.UpdatePersonalInfoResult.OK:
                    TempData["Result"] = "PersonalInfoHasBeenUpdated";
                    return(RedirectToAction("MyProfile"));

                case PartnerBLL.UpdatePersonalInfoResult.EmailAddressAlreadyUsed:
                    AddError("EmailAddress", result.ToString());
                    EditPersonalInfo_Base(connector);
                    return(View(personalInfo));

                default: return(BadRequest());
                }
            }
            else
            {
                EditPersonalInfo_Base(connector);
                return(BadRequestWithErrors(personalInfo));
            }
        }
Ejemplo n.º 7
0
        public ActionResult EditPropertyFeature(Guid propertyId, byte featureId, PropertyFeatureDetailDTO featureDetail)
        {
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
                PartnerBLL.UpdatePropertyFeatureDetailResult result = partnerBLL.UpdatePropertyFeature(Account, propertyId, featureId, featureDetail);
                switch (result)
                {
                case PartnerBLL.UpdatePropertyFeatureDetailResult.OK:
                    TempData["Result"] = "PropertyFeatureDetailHasBeenEdited";
                    return(RedirectToAction("ViewProperty", new { id = propertyId }));

                case PartnerBLL.UpdatePropertyFeatureDetailResult.NotFound: return(HttpNotFound());

                case PartnerBLL.UpdatePropertyFeatureDetailResult.FeatureAlreadyAdded:
                    AddError("Feature", "FeatureAlreadyAdded");
                    EditPropertyFeature_Base(propertyId);
                    return(View(featureDetail));

                default: return(BadRequest());
                }
            }
            else
            {
                EditPropertyFeature_Base(propertyId);
                return(BadRequestWithErrors());
            }
        }
Ejemplo n.º 8
0
        private PropertyDTO AddEditPropertyPicture_Base(PartnerBLL partnerBLL, Guid id)
        {
            PropertyDTO property = partnerBLL.ReadPropertyById(Account, id);

            ViewBag.PropertyId = id;
            return(property);
        }
Ejemplo n.º 9
0
        public ActionResult AddPropertyFeature(Guid id, PropertyFeatureDetailDTO featureDetail)
        {
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
                PartnerBLL.AddPropertyFeatureDetailResult result = partnerBLL.AddPropertyFeatureDetail(Account, id, featureDetail);
                switch (result)
                {
                case PartnerBLL.AddPropertyFeatureDetailResult.OK:
                    TempData["Result"] = "PropertyFeatureDetailHasBeenAdded";
                    return(RedirectToAction("ViewProperty"));

                case PartnerBLL.AddPropertyFeatureDetailResult.NotFound: return(HttpNotFound());

                case PartnerBLL.AddPropertyFeatureDetailResult.FeatureAlreadyAdded:
                    AddError("Feature", "FeatureAlreadyAdded");
                    AddEditPropertyFeature_Base(id);
                    return(View(featureDetail));

                default: return(BadRequest());
                }
            }
            else
            {
                return(AddEditPropertyFeature_Base(id) != null?BadRequestWithErrors() as ActionResult : HttpNotFound());
            }
        }
Ejemplo n.º 10
0
        public ActionResult PublishProperty(Guid id, PublishPropertyDTO request)
        {
            Connector connector = WebApp.Connector;

            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(connector)
                {
                    PublishPropertyEmailSubject  = LocalizationProvider["PublishPropertyEmailSubject"],
                    PublishPropertyEmailTemplate = LocalizationProvider["PublishPropertyEmailTemplate"]
                };
                string baseUrl = new UriBuilder(Request.Url.Scheme, Request.Url.Host, Request.Url.Port).ToString();
                PartnerBLL.PublishPropertyResult result = partnerBLL.PublishProperty(Account, id, request.PaymentMethod, request.PublishMode, baseUrl);
                switch (result)
                {
                case PartnerBLL.PublishPropertyResult.OK:
                    TempData["Result"] = "PropertyHasBeenPaid";
                    return(RedirectToAction("ViewProperty"));

                case PartnerBLL.PublishPropertyResult.NotFound: return(HttpNotFound());

                case PartnerBLL.PublishPropertyResult.PaymentHasBeenRejected:
                    AddError("PaymentMethod", result.ToString());
                    PublishProperty_Base(connector, id);
                    return(View(request));

                default: return(BadRequest());
                }
            }
            else
            {
                PublishProperty_Base(connector, id);
                return(BadRequestWithErrors());
            }
        }
Ejemplo n.º 11
0
        public ActionResult AddCard(AddCardDTO request)
        {
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL           = new PartnerBLL(WebApp.Connector);
                PartnerBLL.AddCardResult result = partnerBLL.AddCard(Account, request.TokenId);
                switch (result)
                {
                case PartnerBLL.AddCardResult.OK:
                    TempData["Result"] = "CardHasBeenAdded";
                    return(RedirectToAction("MyCards"));

                case PartnerBLL.AddCardResult.CardIsNotCredit:
                case PartnerBLL.AddCardResult.CardHasAlreadyBeenAdded:
                case PartnerBLL.AddCardResult.MaximumAmountOfCardsReached:
                    AddError("TokenId", result.ToString());
                    return(View());

                default: return(BadRequest());
                }
            }
            else
            {
                return(BadRequestWithErrors());
            }
        }
Ejemplo n.º 12
0
        public ActionResult ViewInvoice(Guid id)
        {
            PartnerBLL        partnerBLL = new PartnerBLL(WebApp.Connector);
            PartnerInvoiceDTO invoice    = partnerBLL.ReadInvoiceById(Account, id);

            return(invoice != null?View(invoice) as ActionResult : HttpNotFound());
        }
Ejemplo n.º 13
0
        public ActionResult DeletePropertyFeature(Guid propertyId, byte featureId)
        {
            PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);

            if (Request.HttpMethod == "GET")
            {
                PropertyFeatureDetailDTO featureDetail = partnerBLL.ReadPropertyFeatureDetailById(Account, propertyId, featureId);
                if (featureDetail != null)
                {
                    ViewBag.PropertyId = propertyId;
                    return(View(featureDetail));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            else
            {
                PartnerBLL.DeletePropertyFeatureDetailResult result = partnerBLL.DeletePropertyFeatureDetail(Account, propertyId, featureId);
                switch (result)
                {
                case PartnerBLL.DeletePropertyFeatureDetailResult.OK:
                    TempData["Result"] = "PropertyFeatureDetailHasBeenDeleted";
                    return(RedirectToAction("ViewProperty", new { id = propertyId }));

                case PartnerBLL.DeletePropertyFeatureDetailResult.NotFound: return(HttpNotFound());

                default: return(BadRequest());
                }
            }
        }
Ejemplo n.º 14
0
        public ActionResult EditPropertyFeature(Guid propertyId, byte featureId)
        {
            PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
            PropertyFeatureDetailDTO featureDetail = partnerBLL.ReadPropertyFeatureDetailById(Account, propertyId, featureId);

            EditPropertyFeature_Base(propertyId);
            return(View(featureDetail));
        }
Ejemplo n.º 15
0
        public void CreateAPartnerAccountWithAnAlreadyUsedUsername()
        {
            PartnerBLL partnerBLL = new PartnerBLL(TestApp.Connector);
            CountryDTO country    = new CountryDTO()
            {
                Id = "PE"
            };
            DistrictDTO district = new DistrictDTO()
            {
                Country  = country,
                Code     = "150106",
                Province = new ProvinceDTO()
                {
                    Country = country,
                    Code    = "150100",
                    Region  = new RegionDTO()
                    {
                        Country = country,
                        Code    = "150000"
                    }
                }
            };
            PartnerDTO partner = new PartnerDTO()
            {
                Username   = "******",
                Password   = new byte[64],
                FirstName  = "Aldo",
                MiddleName = "Alejandro",
                LastName   = "Astupillo Cáceres",
                Gender     = new GenderDTO()
                {
                    Id = "M"
                },
                EmailAddress      = "*****@*****.**",
                MobileNumber      = "+51989637468",
                CompanyName       = "Hatun Search",
                Address           = "Av. Larco 322",
                Country           = country,
                District          = district,
                PhoneNumber       = "+5115474849",
                Website           = "https://hatunsearch.me",
                PreferredCurrency = new CurrencyDTO()
                {
                    Id = "PEN"
                },
                PreferredLanguage = new LanguageDTO()
                {
                    Id = "ES"
                }
            };

            PartnerBLL.SignupResult result = partnerBLL.Signup(partner, "https://partners.hatunsearch.me", "https://partners.hatunsearch.me/es-pe/accounts/signup/verification");
            Assert.AreEqual(PartnerBLL.SignupResult.UsernameAlreadyUsed, result);
        }
Ejemplo n.º 16
0
        private bool AnswerQuestion_Base(Guid id)
        {
            PartnerBLL          partnerBLL = new PartnerBLL(WebApp.Connector);
            CustomerQuestionDTO question   = partnerBLL.ReadCustomerQuestionById(Account, id);
            bool isAnswerable = question != null && question.Answer == null;

            if (isAnswerable)
            {
                ViewBag.Question = question;
            }
            return(isAnswerable);
        }
Ejemplo n.º 17
0
 public ActionResult EditPreferences(PartnerPreferencesDTO preferences)
 {
     if (ModelState.IsValid)
     {
         PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
         partnerBLL.UpdatePreferences(Account.Id, preferences);
         TempData["Result"] = "PreferencesHaveBeenUpdated";
         return(RedirectToAction("MyProfile"));
     }
     else
     {
         EditPreferences_Base();
         return(BadRequestWithErrors(preferences));
     }
 }
Ejemplo n.º 18
0
 public ActionResult EditCompanyInfo(PartnerCompanyInfoDTO companyInfo)
 {
     if (ModelState.IsValid)
     {
         PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
         partnerBLL.UpdateCompanyInfo(Account.Id, companyInfo);
         TempData["Result"] = "CompanyInfoHasBeenUpdated";
         return(RedirectToAction("MyProfile"));
     }
     else
     {
         EditCompanyInfo_Base();
         return(BadRequestWithErrors(companyInfo));
     }
 }
Ejemplo n.º 19
0
        public ActionResult EditPropertyPicture(Guid propertyId, Guid pictureId)
        {
            PartnerBLL  partnerBLL = new PartnerBLL(WebApp.Connector);
            PropertyDTO property   = AddEditPropertyPicture_Base(partnerBLL, propertyId);

            if (property != null)
            {
                PropertyPictureDTO picture = partnerBLL.ReadPropertyPictureById(Account, propertyId, pictureId);
                return(picture != null?View(picture) as ActionResult : HttpNotFound());
            }
            else
            {
                return(HttpNotFound());
            }
        }
Ejemplo n.º 20
0
        private bool PublishProperty_Base(Connector connector, Guid propertyId)
        {
            PartnerBLL          partnerBLL          = new PartnerBLL(connector);
            CurrencyExchangeBLL currencyExchangeBLL = new CurrencyExchangeBLL(connector);
            PublishModeBLL      publishModeBLL      = new PublishModeBLL(connector);
            PropertyDTO         property            = partnerBLL.ReadPropertyById(Account, propertyId);
            bool result = property != null && !property.HasBeenPaid;

            if (result)
            {
                ViewBag.CurrenciesExchanges = currencyExchangeBLL.ReadByTo(Account.PreferredCurrency.Id);
                ViewBag.PublishModes        = publishModeBLL.ReadAll();
                ViewBag.Property            = property;
            }
            return(result);
        }
Ejemplo n.º 21
0
        public ActionResult EditProperty(Guid id)
        {
            Connector   connector  = WebApp.Connector;
            PartnerBLL  partnerBLL = new PartnerBLL(connector);
            PropertyDTO property   = partnerBLL.ReadPropertyById(Account, id);

            if (property != null && (!property.HasBeenPaid || (property.HasBeenReviewed && !property.HasBeenPublished)))
            {
                AddEditProperty_BaseGet(connector);
                return(View(property));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Ejemplo n.º 22
0
        public ActionResult ViewCustomerQuestion(Guid id)
        {
            PartnerBLL          partnerBLL = new PartnerBLL(WebApp.Connector);
            CustomerQuestionDTO question   = partnerBLL.ReadCustomerQuestionById(Account, id);

            if (question != null)
            {
                if (!question.HasQuestionBeenRead)
                {
                    partnerBLL.MarkQuestionAsRead(Account, id);
                }
                return(View(question));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Ejemplo n.º 23
0
        public void ChangePasswordTest()
        {
            PartnerBLL partnerBLL = new PartnerBLL(TestApp.Connector)
            {
                ChangePasswordEmailSubject  = "Cambio de contraseña en su cuenta",
                ChangePasswordEmailTemplate = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"></head><body style=\"font-family: Roboto, 'Segoe UI', sans-serif; margin: 24px;\"><img src=\"{0}\" width=\"192\" /><h3>Cambio de contraseña en su cuenta</h3><p>¡Hola, {1}!</p><p>Recientemente se ha cambiado su contraseña de su cuenta de Hatun Search. Por motivos de seguridad, le enviamos esta notificación para que, en caso usted no haya realizado dicho cambio, pueda comunicarse con nosotros para poder tomar medidas con el fin de proteger su cuenta.</p><p>Si usted no realizó el cambio antes mencionado, por favor, escríbanos un mensaje a <a href=\"mailto:[email protected]\">[email protected]</a> indicándonos dicho inconveniente. Le brindaremos ayuda para recuperar el control de su cuenta.</p><p>Saludos,<br>Departamento de Atención al Cliente</p><p>Por favor, no responda directamente a este mensaje, ya que ha sido enviado desde un correo electrónico que no se supervisa.</p></body></html>"
            };

            EmailSender.DefaultAddress = new MailAddress("*****@*****.**", "Hatun Search");
            PartnerDTO previousPartner = partnerBLL.ReadByUsername("aldoastupillo");

            partnerBLL.ChangePassword(previousPartner, "1234567890", "https://partners.hatunsearch.me");
            PartnerDTO currentPartner = partnerBLL.ReadByUsername("aldoastupillo");
            string     currentPassword = FormatHelper.FromArrayToHexString(currentPartner.Password), previousPassword = FormatHelper.FromArrayToHexString(previousPartner.Password);

            Assert.AreNotEqual(previousPassword, currentPassword);
            partnerBLL.ChangePassword(previousPartner, "12345678", "https://partners.hatunsearch.me");
        }
Ejemplo n.º 24
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     base.OnActionExecuting(filterContext);
     ViewBag.ControllerName = ControllerName;
     ViewBag.ActionName     = filterContext.ActionDescriptor.ActionName;
     if (filterContext.Result == null)
     {
         PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);
         PartnerDTO partner    = partnerBLL.ReadById(CurrentSession.Partner.Id);
         string     result     = TempData["Result"] as string;
         Account         = partner;
         ViewBag.Account = partner;
         if (result != null)
         {
             ViewBag.Result = result;
         }
     }
 }
Ejemplo n.º 25
0
        public ActionResult AddPropertyPicture(Guid id, AddPropertyPictureDTO request)
        {
            bool hasAValidPicture = false;

            try { using (new Bitmap(request.Picture.InputStream)) { hasAValidPicture = true; } }
            catch { }
            PartnerBLL  partnerBLL = new PartnerBLL(WebApp.Connector);
            PropertyDTO property   = AddEditPropertyPicture_Base(partnerBLL, id);

            if (ModelState.IsValid)
            {
                if (hasAValidPicture)
                {
                    PropertyPictureDTO picture = new PropertyPictureDTO()
                    {
                        Property    = property,
                        Description = request.Description
                    };
                    PartnerBLL.AddPropertyPictureResult result = partnerBLL.AddPropertyPicture(Account, id, picture);
                    switch (result)
                    {
                    case PartnerBLL.AddPropertyPictureResult.OK:
                        string imgRepository = HostingEnvironment.MapPath("~/img");
                        request.Picture.SaveAs($"{imgRepository}/{picture.Id}.bin");
                        TempData["Result"] = "PropertyPictureHasBeenAdded";
                        return(RedirectToAction("ViewProperty"));

                    case PartnerBLL.AddPropertyPictureResult.NotFound: return(HttpNotFound());

                    default: return(BadRequest());
                    }
                }
                else
                {
                    AddError("Picture", "FileIsNotAValidPicture");
                    return(View(request));
                }
            }
            else
            {
                return(property != null?BadRequestWithErrors() as ActionResult : HttpNotFound());
            }
        }
Ejemplo n.º 26
0
        public ActionResult DeletePropertyPicture(Guid propertyId, Guid pictureId)
        {
            PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector);

            if (Request.HttpMethod == "GET")
            {
                PropertyPictureDTO picture = partnerBLL.ReadPropertyPictureById(Account, propertyId, pictureId);
                if (picture != null)
                {
                    ViewBag.PropertyId = propertyId;
                    return(View(picture));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            else
            {
                PartnerBLL.DeletePropertyPictureResult result = partnerBLL.DeletePropertyPicture(Account, propertyId, pictureId);
                switch (result)
                {
                case PartnerBLL.DeletePropertyPictureResult.OK:
                    TempData["Result"] = "PropertyPictureHasBeenDeleted";
                    try
                    {
                        string image = HostingEnvironment.MapPath($"~/img/{pictureId}.img");
                        System.IO.File.Delete(image);
                    }
                    catch { }
                    return(RedirectToAction("ViewProperty", new { id = propertyId }));

                case PartnerBLL.DeletePropertyPictureResult.NotFound: return(HttpNotFound());

                default: return(BadRequest());
                }
            }
        }
Ejemplo n.º 27
0
        public ActionResult EditPropertyPicture(Guid propertyId, Guid pictureId, PropertyPictureDTO picture)
        {
            PartnerBLL  partnerBLL = new PartnerBLL(WebApp.Connector);
            PropertyDTO property   = AddEditPropertyPicture_Base(partnerBLL, propertyId);

            if (ModelState.IsValid)
            {
                PartnerBLL.UpdatePropertyPictureResult result = partnerBLL.UpdatePropertyPicture(Account, propertyId, pictureId, picture);
                switch (result)
                {
                case PartnerBLL.UpdatePropertyPictureResult.OK:
                    TempData["Result"] = "PropertyPictureHasBeenEdited";
                    return(RedirectToAction("ViewProperty", new { id = propertyId }));

                case PartnerBLL.UpdatePropertyPictureResult.NotFound: return(HttpNotFound());

                default: return(BadRequest());
                }
            }
            else
            {
                return(property != null?BadRequestWithErrors() as ActionResult : HttpNotFound());
            }
        }
Ejemplo n.º 28
0
        public ActionResult AddProperty(PropertyDTO property)
        {
            Connector connector = WebApp.Connector;

            AddEditProperty_BasePost(connector, property);
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(connector);
                PartnerBLL.AddPropertyResult result = partnerBLL.AddProperty(Account, property);
                switch (result)
                {
                case PartnerBLL.AddPropertyResult.OK:
                    TempData["Result"] = "PropertyHasBeenAdded";
                    return(RedirectToAction("Properties"));

                default: return(BadRequest());
                }
            }
            else
            {
                AddEditProperty_BaseGet(connector);
                return(BadRequestWithErrors(property));
            }
        }