Пример #1
0
        public async Task <ActionResult> IndividualSector(IndividualLeadViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var result_ = await PostResourceAsync <bool>("api/Lead/Individual/GetLeadsByMobile", model);


            if (!result_.Result)
            {
                if (!await IsProfileCompleted())
                {
                    var currentUser = UserManager.FindById(User.Identity.GetUserId());

                    var contactResult = await GetResourceAsync <dynamic>("api/contact/" + currentUser.CrmUserId);

                    ContactViewModel contact = contactResult.ToObject <ContactViewModel>();

                    contact.CityId   = model.CityId ?? contact.CityId;
                    contact.IdNumber = model.IdNumber ?? contact.IdNumber;
                    contact.JobTitle = model.JobTitle ?? contact.JobTitle;
                    contact.RegionId = model.RegionId ?? contact.RegionId;

                    contact.Email         = model.Email ?? contact.Email;
                    contact.NationalityId = model.NationalityId ?? contact.NationalityId;
                    contact.GenderId      = model.GenderId ?? contact.GenderId;

                    await PostResourceAsync <ContactViewModel>("api/contact/UpdateProfile", contact);
                }

                var result = await PostResourceAsync <BusinessLeadViewModel>("api/Lead/Individual/Create", model);

                if (result.StatusCode == HttpStatusCode.OK)
                {
                    return(View("Success", SuccessLeadRequest()));
                }

                ModelState.AddModelError("", result.StatusCode == HttpStatusCode.BadRequest ? result.StatusMessage : "Something went wrong");
                return(View(model));
            }
            else
            {
                ViewBag.ErrorMessage = Lang == Language.Arabic ? "هذا العميل لديه طلبـات سابقة" : "This client has prior requests";
                return(View(model));
            }
        }
Пример #2
0
        public async Task <ActionResult> IndividualSector()
        {
            var currentUser = UserManager.FindById(User.Identity.GetUserId());
            var result      = await GetResourceAsync <dynamic>("api/contact/" + currentUser.CrmUserId);

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

            ContactViewModel contact = result.ToObject <ContactViewModel>();
            var model = new IndividualLeadViewModel(contact);

            return(View(model));
        }