Example #1
0
        public ActionResult UpdateHomeContent(IFormCollection form)
        {
            HomeContent about   = JsonConvert.DeserializeObject <HomeContent>(form["aboutInfo"]);
            var         aboutDB = homeService.GetHomeContent(about.Id);

            try
            {
                if (aboutDB.Id > 0)
                {
                    aboutDB.Title      = about.Title;
                    aboutDB.Desciption = about.Desciption;
                    aboutDB.UpdateDate = DateTime.Now;
                    homeService.UpdateHomeContent(aboutDB);
                    return(Json(new { success = true }));
                }
                else
                {
                    return(Json(new { success = false }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }));
            }
        }
Example #2
0
        public IActionResult EditHomeContent(int?id, EditHomeContentViewModel model)
        {
            if (id == null)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.File != null)
                    {
                        string upload   = Path.Combine(_hosting.WebRootPath, @"image");
                        string fullpath = Path.Combine(upload, model.File.FileName);
                        model.File.CopyTo(new FileStream(fullpath, FileMode.Create));
                        model.Image = model.File.FileName;
                    }

                    var homecontent = new HomeContent
                    {
                        Id        = model.Id,
                        Paragraph = model.Paragraph,
                        Image     = model.Image
                    };
                    _context.Entry(homecontent).State = EntityState.Modified;
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                return(RedirectToAction(nameof(HomeContentIndex)));
            }
            return(View(model));
        }
        public void UpsertStaticHomePageDataAsyncShouldValidate(HomeContent homeInput, JArray homeDBData, dynamic expectedResult)
        {
            var expectedName = "HomePage";
            var dbResponse   = dynamicQueries.FindItemsWhereWithLocationAsync(cosmosDbSettings.StaticResourcesCollectionId, Constants.Name, homeInput.Name, new Location());

            dbResponse.ReturnsForAnyArgs(homeDBData);

            Document       updatedDocument = new Document();
            JsonTextReader reader          = new JsonTextReader(new StringReader(StaticResourceTestData.updatedHomeContent));

            updatedDocument.LoadFrom(reader);

            backendDatabaseService.CreateItemAsync <dynamic>(
                Arg.Any <HomeContent>(),
                Arg.Any <string>()).ReturnsForAnyArgs <Document>(updatedDocument);

            backendDatabaseService.UpdateItemAsync <dynamic>(
                Arg.Any <string>(),
                Arg.Any <HomeContent>(),
                Arg.Any <string>()).ReturnsForAnyArgs <Document>(updatedDocument);

            //act
            var response = staticResourceBusinessLogic.UpsertStaticHomePageDataAsync(homeInput);

            expectedResult = JsonConvert.SerializeObject(expectedResult);
            var actualResult = JsonConvert.SerializeObject(response.Result);

            //assert
            Assert.Contains(expectedName, expectedResult);
        }
 public ActionResult Create(HomeContent collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool SaveResult = _HomeDb.InsertHomeContent(collection);
             if (SaveResult)
             {
                 return(Redirect("/"));
             }
             else
             {
                 return(View());
             }
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,AuthoredBy,Body,DatePosted,SubTitle,Title")] HomeContent homeContent)
        {
            if (id != homeContent.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(homeContent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HomeContentExists(homeContent.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(homeContent));
        }
Example #6
0
        public async Task <IActionResult> PutHomeContent([FromRoute] int id, [FromBody] HomeContent homeContent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != homeContent.HomeContentId)
            {
                return(BadRequest());
            }

            _context.Entry(homeContent).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HomeContentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #7
0
        public IActionResult Index(HomeContent data)
        {
            // property injection of the Collator used as the gateway for the data API so that
            // the model can fetch information about other content items
            data.Collator = lyn.Collator;

            return(View(data));
        }
Example #8
0
        public async Task <IActionResult> UpsertStaticHomePageDataAsync([FromBody] HomeContent homePageContent)
        {
            if (await userRoleBusinessLogic.ValidateOrganizationalUnit(homePageContent.OrganizationalUnit))
            {
                var contents = await staticResourceBusinessLogic.UpsertStaticHomePageDataAsync(homePageContent);

                return(Ok(contents));
            }
            return(StatusCode(403));
        }
Example #9
0
        public ActionResult EditHomeContent(int id)
        {
            HomeContent about = new HomeContent();

            about = homeService.GetHomeContent(id);

            var JSON = Json(new { about = about, success = true });

            return(JSON);
        }
Example #10
0
 public ActionResult Edit([Bind(Include = "Id,home_content,home_lang_id")] HomeContent homeContent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(homeContent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.home_lang_id = new SelectList(db.Languages, "Id", "language1", homeContent.home_lang_id);
     return(View(homeContent));
 }
Example #11
0
        public async Task <IActionResult> Create([Bind("ID,AuthoredBy,Body,DatePosted,SubTitle,Title")] HomeContent homeContent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(homeContent);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(homeContent));
        }
Example #12
0
 private void Home_Hide()
 {   // changes the displayed items to fit non-home screens
     PathTxt.Show();
     PathField.Show();
     ScanBtn.Show();
     PathBtn.Show();
     HomeContent.Hide();
     HomePanel.Hide();
     SettingsBox.Hide();
     SettingsTitle.Hide();
 }
Example #13
0
        public async Task <IActionResult> PostHomeContent([FromBody] HomeContent homeContent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.HomeContent.Add(homeContent);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHomeContent", new { id = homeContent.HomeContentId }, homeContent));
        }
Example #14
0
        public ActionResult Create([Bind(Include = "Id,home_content,home_lang_id")] HomeContent homeContent)
        {
            if (ModelState.IsValid)
            {
                db.HomeContents.Add(homeContent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.home_lang_id = new SelectList(db.Languages, "Id", "language1", homeContent.home_lang_id);
            return(View(homeContent));
        }
Example #15
0
        // GET: Admin/HomeContents/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HomeContent homeContent = db.HomeContents.Find(id);

            if (homeContent == null)
            {
                return(HttpNotFound());
            }
            return(View(homeContent));
        }
Example #16
0
        // GET: Admin/HomeContents/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HomeContent homeContent = db.HomeContents.Find(id);

            if (homeContent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.home_lang_id = new SelectList(db.Languages, "Id", "language1", homeContent.home_lang_id);
            return(View(homeContent));
        }
Example #17
0
 public async Task<dynamic> UpsertStaticHomePageDataAsync(HomeContent homePageContent)
 {
     dynamic result = null;
     var pageDBData = await dbClient.FindItemsWhereWithLocationAsync(dbSettings.StaticResourcesCollectionId, Constants.Name, homePageContent.Name, homePageContent.Location.FirstOrDefault());
     if (pageDBData?.Count > 0)
     {
         string id = pageDBData[0].id;
         homePageContent.Id = id;
         var pageDocument = JsonUtilities.DeserializeDynamicObject<object>(homePageContent);
         result = await dbService.UpdateItemAsync(id, pageDocument, dbSettings.StaticResourcesCollectionId);
     }
     else
     {
         var pageDocument = JsonUtilities.DeserializeDynamicObject<object>(homePageContent);
         result = await dbService.CreateItemAsync(pageDocument, dbSettings.StaticResourcesCollectionId);
     }
     return result;
 }
Example #18
0
        private async void Button_Add_Clicked(object sender, EventArgs e)
        {
            if (Entry_Title.Text != "" || Entry_Content.Text != "")
            {
                HomeContent content = new HomeContent()
                {
                    Title   = Entry_Title.Text,
                    Content = Entry_Content.Text
                };

                await App.HomeDatabase.Insert(content);

                await Navigation.PopAsync();
            }
            else
            {
                await DisplayAlert("Error", "Please make sure that the title entry and the content entry are not empty", "OK");
            }
        }
Example #19
0
        public ActionResult AddHomeContent(IFormCollection form)
        {
            AboutVM about = JsonConvert.DeserializeObject <AboutVM>(form["aboutInfo"]);

            try
            {
                HomeContent data = new HomeContent();
                data.Title      = about.Title;
                data.Desciption = about.Description;
                data.AddDate    = DateTime.Now;
                data.Status     = 1;
                homeService.InsertHomeContent(data);
                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }));
            }
        }
        public ActionResult HomeContent(HomeContent HomeContent, int?cid)
        {
            NewPolicyDetailsClass HCmodel = new NewPolicyDetailsClass();
            List <SelectListItem> HCList  = new List <SelectListItem>();

            HCList = HCmodel.excessRate();
            if (cid != null)
            {
                ViewBag.cid            = cid;
                HomeContent.CustomerId = cid.Value;
            }
            else
            {
                ViewBag.cid = HomeContent.CustomerId;
            }
            HomeContent.ExcesspayObj.ExcessList = HCList;
            var    db       = new MasterDataEntities();
            string policyid = null;

            Session["profileId"] = null;
            Session["UnId"]      = null;
            string actionname     = null;
            string controllername = null;

            Session["hombud"] = null;
            if (Session["Actname"] != null)
            {
                actionname = Session["Actname"].ToString();
            }
            if (Session["controller"] != null)
            {
                controllername = Session["controller"].ToString();
            }
            //if (actionname != null && controllername != null)
            //{
            //    return RedirectToAction(actionname, controllername, new { cid = HomeContent.CustomerId, PcId = HomeContent.PcId });
            //}
            return(RedirectToAction("Valuables", new { cid = HomeContent.CustomerId, PcId = HomeContent.PcId }));
        }
Example #21
0
        public async Task ModifyArticle(HomeContentCreateEditModel content)
        {
            if (string.IsNullOrWhiteSpace(content.SectionHeading) ||
                string.IsNullOrWhiteSpace(content.SectionContent) ||
                string.IsNullOrWhiteSpace(content.ArticleHeading) ||
                string.IsNullOrWhiteSpace(content.ArticleContent))
            {
                throw new ArgumentException("None of home content data could be an empty string");
            }



            HomeContent persistedContent = await this.db.HomeContent.FirstOrDefaultAsync();

            if (persistedContent != null)
            {
                persistedContent.SectionHeading = content.SectionHeading;
                persistedContent.SectionContent = content.SectionContent;
                persistedContent.ArticleHeading = content.ArticleHeading;
                persistedContent.ArticleContent = content.ArticleContent;
            }

            else
            {
                HomeContent homeContent = new HomeContent
                {
                    ArticleHeading = content.ArticleHeading,
                    ArticleContent = content.ArticleContent,
                    SectionHeading = content.SectionHeading,
                    SectionContent = content.SectionContent
                };

                await this.db.HomeContent.AddAsync(homeContent);
            }

            await this.db.SaveChangesAsync();
        }
Example #22
0
        private async Task SeedData(DataContext context, UserManager <User> userManagerService)
        {
            if (context.Addresses.Count() == 0)
            {
                context.Addresses.Add(new Models.Address
                {
                    address1   = "1000 Lakeshore Dr",
                    address2   = "",
                    city       = "Penticton",
                    province   = "British Columbia",
                    country    = "Canada",
                    postalCode = "V2A 1C1"
                });
            }

            context.SaveChanges();

            if (context.Companies.Count() == 0)
            {
                context.Companies.Add(new Company
                {
                    name         = "Salty's Beachhouse",
                    contactName  = "Alexandra Bonnett",
                    contactPhone = "250-493-5001",
                    addressId    = context.Addresses.FirstOrDefault().AddressId,
                    timezone     = "Pacific Standard Time"
                });
            }
            else
            {
                var company = context.Companies.First();

                if (company.timezone == null || company.timezone == "")
                {
                    company.timezone = "Pacific Standard Time";
                }
            }

            context.SaveChanges();

            if (context.Companies.First().addressId == null)
            {
                context.Companies.First().addressId = context.Addresses.First().AddressId;
            }

            context.SaveChanges();

            if (context.Users.Count() == 0)
            {
                var user = new User
                {
                    FirstName   = "Donovan",
                    LastName    = "Rogall",
                    Avatar      = "avatar",
                    Role        = "leader",
                    PhoneNumber = "555-555-5555",
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    AddressId   = context.Addresses.FirstOrDefault().AddressId,
                };
                var result = await userManagerService.CreateAsync(user, "end422");

                user = new User
                {
                    FirstName   = "Alexandra",
                    LastName    = "Bonnett",
                    Avatar      = "avatar",
                    Role        = "leader",
                    PhoneNumber = "555-555-5555",
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    AddressId   = context.Addresses.FirstOrDefault().AddressId,
                };
                result = await userManagerService.CreateAsync(user, "mysaltys2019");
            }

            context.SaveChanges();

            if (context.HomeContent.Count() == 0)
            {
                var content = new HomeContent
                {
                    title           = "My Salty's Content 1",
                    description     = "This is the content. Obviously it could be much longer and more meaningful",
                    backgroundImage = "",
                    createdBy       = "",
                    createdOn       = DateTime.Now
                };
                context.HomeContent.Add(content);
                content = new HomeContent
                {
                    title           = "My Salty's Content 1",
                    description     = "This is the content. Obviously it could be much longer and more meaningful",
                    backgroundImage = "",
                    createdBy       = "",
                    createdOn       = DateTime.Now
                };
                context.HomeContent.Add(content);
                content = new HomeContent
                {
                    title           = "My Salty's Content 2",
                    description     = "This is the content. Obviously it could be much longer and more meaningful",
                    backgroundImage = "",
                    createdBy       = "",
                    createdOn       = DateTime.Now
                };
                context.HomeContent.Add(content);
                content = new HomeContent
                {
                    title           = "My Salty's Content 3",
                    description     = "This is the content. Obviously it could be much longer and more meaningful",
                    backgroundImage = "",
                    createdBy       = "",
                    createdOn       = DateTime.Now
                };
                context.HomeContent.Add(content);
                content = new HomeContent
                {
                    title           = "My Salty's Content 4",
                    description     = "This is the content. Obviously it could be much longer and more meaningful",
                    backgroundImage = "",
                    createdBy       = "",
                    createdOn       = DateTime.Now
                };
                context.HomeContent.Add(content);
                content = new HomeContent
                {
                    title           = "My Salty's Content 5",
                    description     = "This is the content. Obviously it could be much longer and more meaningful",
                    backgroundImage = "",
                    createdBy       = "",
                    createdOn       = DateTime.Now
                };
            }

            context.SaveChanges();
        }
Example #23
0
        public void DeleteHomeContent(int id)
        {
            HomeContent HomeContent = HomeContentRepository.Get(id);

            HomeContentRepository.Remove(HomeContent);
        }
 public void UpdateHomeContent(HomeContent homeContent)
 {
     _iHomeContentRepository.Update(homeContent);
     Save();
 }
Example #25
0
 public IActionResult Index(Node node, HomeContent content, ShoppingCart shoppingCart)
 {
     return(View());
 }
 public void CreateHomeContent(HomeContent homeContent)
 {
     _iHomeContentRepository.Add(homeContent);
     Save();
 }
        public HomeContent GetHomeContent(string authorization)
        {
            var itemFood = new ItemFoodDto()
            {
                FoodId         = 1,
                RestaurantId   = 1,
                FoodCost       = 34000,
                FoodName       = "Homestyle Crispy Chicken",
                RestaurantName = "McDonald's",
                FoodImage      = "https://cdn.shopify.com/s/files/1/0269/5967/5490/products/6.2.jpg"
            };

            var itemRestaurant = new ItemRestaurantHoriDto()
            {
                RestaurantId    = 1,
                RestaurantName  = "McDonald's® (Adams & Wells)",
                RestaurantImage = "http://52.187.117.17/nwork-api/image/0b0b6588-52d3-42d1-a4e8-6b949561957f.jfif"
            };

            var itemRestaurant1 = new ItemRestaurantHoriDto()
            {
                RestaurantId    = 1,
                RestaurantName  = "McDonald's® (Adams & Wells)",
                RestaurantImage = "https://mcdonalds.vn/uploads/2018/gacay_squared-rev.jpg"
            };

            var itemCollection1 = new ItemCollectionDto()
            {
                CollectionId       = 1,
                CollectionTitle    = "Let's Eat Pizza With Emily",
                CollectionSubtitle = "Delicious and nutritious",
                CollectionImage    = "https://scontent.fdad3-2.fna.fbcdn.net/v/t1.15752-9/s2048x2048/149581589_748881315744891_4814137521680383224_n.jpg?_nc_cat=107&ccb=3&_nc_sid=ae9488&_nc_ohc=K_qXkTXFt2MAX8ua8Or&_nc_ht=scontent.fdad3-2.fna&tp=7&oh=e99582684eb28ce343bd3268883d2a2e&oe=605267CC"
            };

            var itemHomeCollection1 = new ItemListHomeDto()
            {
                Id             = 1,
                Title          = "Delicious food at Chicago",
                Subtitle       = "Order now to get your meal served in minutes",
                Type           = "collection",
                ListCollection = new List <ItemCollectionDto>()
                {
                    itemCollection1, itemCollection1, itemCollection1, itemCollection1, itemCollection1, itemCollection1
                }
            };

            var itemHomeRestaurant = new ItemListHomeDto()
            {
                Id             = 2,
                Title          = "Tasty snack near you",
                Subtitle       = "Too good to be missed get the deals now!",
                Type           = "restaurant",
                ListRestaurant = new List <ItemRestaurantHoriDto>()
                {
                    itemRestaurant, itemRestaurant1, itemRestaurant, itemRestaurant1, itemRestaurant, itemRestaurant1
                }
            };

            var itemHomeFood = new ItemListHomeDto()
            {
                Id       = 3,
                Title    = "Hot Item Today",
                Subtitle = "Order now to get your meal served in minutes",
                Type     = "food",
                ListFood = new List <ItemFoodDto>()
                {
                    itemFood, itemFood, itemFood, itemFood, itemFood, itemFood, itemFood, itemFood
                }
            };

            var itemBanner = new ItemBannerDto()
            {
                Id    = 1,
                Image = "http://channel.mediacdn.vn/2019/1/20/image005-15479948829561514367436.jpg"
            };

            var itemCategory = new ItemCategoryDto()
            {
                CategoryId = 1,
                Title      = "Bread",
                Image      = "http://52.187.117.17/nwork-api/image/6bd41860-95f3-4b20-a42c-2a6aceadf54e.png"
            };

            var itemCategory2 = new ItemCategoryDto()
            {
                CategoryId = 1,
                Title      = "Hamburger",
                Image      = "http://52.187.117.17/nwork-api/image/610431f9-32e7-4aad-8b24-88d89668209c.jpg"
            };

            var itemCategory3 = new ItemCategoryDto()
            {
                CategoryId = 1,
                Title      = "Cake",
                Image      = "http://52.187.117.17/nwork-api/image/9d63bd85-a3cc-4e48-8039-bd2c45bcbdc8.png"
            };

            var itemRestaurantVerti = new ItemRestaurantVertiDto()
            {
                RestaurantId    = 2,
                RestaurantName  = "KFC Camberwell - Church Street",
                RestaurantType  = "Fried Chicken - American - Fast Food",
                RestaurantImage = "https://d1ralsognjng37.cloudfront.net/a7002177-10a0-4cee-98e3-007e5805fc7e.jpeg",
                RestaurantRate  = 4.5,
                DeliveryTime    = 23,
                Distance        = 5.0
            };

            var contentHome = new HomeContent()
            {
                ListBanner = new List <ItemBannerDto>()
                {
                    itemBanner, itemBanner, itemBanner, itemBanner
                },
                ListCategory = new List <ItemCategoryDto>()
                {
                    itemCategory2, itemCategory2, itemCategory2, itemCategory2, itemCategory2, itemCategory2
                },
                ListHome = new List <ItemListHomeDto>()
                {
                    itemHomeCollection1, itemHomeRestaurant, itemHomeRestaurant
                },
                MoreRestaurant = new List <ItemRestaurantVertiDto>()
                {
                    itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti,
                    itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti,
                    itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti, itemRestaurantVerti
                }
            };

            return(contentHome);
        }
Example #28
0
 public void UpdateHomeContent(HomeContent HomeContent)
 {
     HomeContentRepository.Update(HomeContent);
 }
Example #29
0
 public void InsertHomeContent(HomeContent HomeContent)
 {
     HomeContentRepository.Insert(HomeContent);
 }
        public async System.Threading.Tasks.Task <ActionResult> HomeContent(int cid, int?PcId)
        {
            ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails();
            MasterDataEntities    db          = new MasterDataEntities();
            NewPolicyDetailsClass HCmodel     = new NewPolicyDetailsClass();
            List <SelectListItem> HCList      = new List <SelectListItem>();
            HomeContent           HomeContent = new HomeContent();

            HCList = HCmodel.excessRate();
            string apikey = null;
            //var suburblist = db.IT_Master_GetSuburbList().ToList();
            var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList();

            if (Session["ApiKey"] != null)
            {
                apikey = Session["ApiKey"].ToString();
            }
            else
            {
                return(RedirectToAction("AgentLogin", "Login"));
            }
            //HomeContent.SubUrb = suburblist.Where(s => !string.IsNullOrEmpty(s)).Select(s => new SelectListItem() { Text = s, Value = s }).ToList();
            HomeContent.AddressObj              = new Addresses();
            HomeContent.LocationObj             = new LocationNew();
            HomeContent.CosttoreplaceObj        = new CostToReplaces();
            HomeContent.CosttoreplaceObj.EiId   = 60273;
            HomeContent.DescriptionObj          = new Descriptions();
            HomeContent.DescriptionObj.EiId     = 60285;
            HomeContent.SuminsuredObj           = new SumInsures();
            HomeContent.SuminsuredObj.EiId      = 60287;
            HomeContent.TotalcoverObj           = new TotalCovers();
            HomeContent.TotalcoverObj.EiId      = 60289;
            HomeContent.YearclaimObj            = new YearClaims();
            HomeContent.YearclaimObj.EiId       = 60301;
            HomeContent.ExcesspayObj            = new ExcessesPay();
            HomeContent.ExcesspayObj.ExcessList = HCList;
            HomeContent.ExcesspayObj.EiId       = 60303;
            HomeContent.ImposedObj              = new Imposednew();
            string policyid = null;
            List <SessionModel>    PolicyInclustions = new List <SessionModel>();
            CommonUseFunctionClass cmn = new CommonUseFunctionClass();

            HomeContent.NewSections = new List <string>();
            var Policyincllist = Session["Policyinclustions"] as List <SessionModel>;

            if (Session["Policyinclustions"] != null)
            {
                #region Policy Selected or not testing

                // var Suburb = new List<KeyValuePair<string, string>>();
                // List<SelectListItem> listItems = new List<SelectListItem>();
                HomeContent.PolicyInclusions = new List <SessionModel>();
                HomeContent.PolicyInclusions = Policyincllist;
                HomeContent.NewSections      = cmn.NewSectionHome(HomeContent.PolicyInclusions);
                if (Policyincllist != null)
                {
                    if (Policyincllist.Exists(p => p.name == "Home Content" || p.name == "Home Contents"))
                    {
                    }
                    else if (Policyincllist.Exists(p => p.name == "Valuables"))
                    {
                        return(RedirectToAction("Valuables", "HomeContentValuable", new { cid = cid }));
                    }
                    else if (Policyincllist.Exists(p => p.name == "Farm Property"))
                    {
                        return(RedirectToAction("FarmContents", "Farm", new { cid = cid }));
                    }
                    else if (Policyincllist.Exists(p => p.name == "Liability"))
                    {
                        return(RedirectToAction("LiabilityCover", "Liabilities", new { cid = cid }));
                    }
                    else if (Policyincllist.Exists(p => p.name == "Motor" || p.name == "Motors"))
                    {
                        return(RedirectToAction("VehicleDescription", "MotorCover", new { cid = cid }));
                    }
                    else if (Policyincllist.Exists(p => p.name == "Boat"))
                    {
                        return(RedirectToAction("BoatDetails", "Boat", new { cid = cid }));
                    }

                    else if (Policyincllist.Exists(p => p.name == "Pet" || p.name == "Pets"))
                    {
                        return(RedirectToAction("PetsCover", "Pets", new { cid = cid }));
                    }
                    else if (Policyincllist.Exists(p => p.name == "Travel"))
                    {
                        return(RedirectToAction("TravelCover", "Travel", new { cid = cid }));
                    }

                    if (Policyincllist.Exists(p => p.name == "Home Content" || p.name == "Home Contents"))
                    {
                        if (Session["unId"] == null && Session["profileId"] == null)
                        {
                            Session["unId"]      = Policyincllist.Where(p => p.name == "Home Content" || p.name == "Home Contents").Select(p => p.UnitId).First();
                            Session["profileId"] = Policyincllist.Where(p => p.name == "Home Content" || p.name == "Home Contents").Select(p => p.ProfileId).First();
                        }
                    }
                    else
                    {
                        return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId }));
                    }
                    //else
                    //{
                    //    return RedirectToAction("PremiumDetails", "Customer", new { cid = cid });
                    //}
                }
                #endregion
            }
            int unid      = 0;
            int profileid = 0;
            if (PcId != null && PcId.HasValue && PcId > 0)
            {
                if (Session["unId"] != null && Session["profileId"] != null)
                {
                    unid      = Convert.ToInt32(Session["unId"]);
                    profileid = Convert.ToInt32(Session["profileId"]);
                }
                else
                {
                    if (policyinclusions.Exists(p => p.Name == "Home Contents"))
                    {
                        unid      = policyinclusions.Where(p => p.Name == "Home Contents").Select(p => p.UnId).FirstOrDefault();
                        profileid = policyinclusions.Where(p => p.Name == "Home Contents").Select(p => p.UnId).FirstOrDefault();
                    }
                    else
                    {
                        return(RedirectToAction("Valuables", "HomeContentValuable", new { cid = cid, PcId = PcId }));
                    }
                }
                HomeContent.PolicyInclusion = policyinclusions;
                if (unid == null || unid == 0)
                {
                    unid      = unitdetails.SectionData.UnId;
                    profileid = unitdetails.SectionData.ProfileUnId;
                }
            }
            bool       policyinclusion = policyinclusions.Exists(p => p.Name == "Home Contents");
            HttpClient hclient         = new HttpClient();
            string     url             = System.Configuration.ConfigurationManager.AppSettings["APIURL"];
            hclient.BaseAddress = new Uri(url);
            hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            if (PcId != null && PcId.HasValue)
            {
                HomeContent.ExistingPolicyInclustions = policyinclusions;
                HomeContent.NewSections = cmn.NewSectionP(policyinclusions);
                //int sectionId = policyinclusions.Where(p => p.Name == "Home Contents" && p.UnitNumber == unid).Select(p => p.UnId).FirstOrDefault();
                //int? profileunid = policyinclusions.Where(p => p.Name == "Home Contents" && p.ProfileUnId == profileid).Select(p => p.ProfileUnId).FirstOrDefault();
                HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid);

                var EmpResponse = getunit.Content.ReadAsStringAsync().Result;
                if (EmpResponse != null)
                {
                    unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse);
                }
            }
            else if (PcId == null && Session["unId"] != null && (Session["profileId"] != null))
            {
                unid      = Convert.ToInt32(Session["unId"]);
                profileid = Convert.ToInt32(Session["profileId"]);
                HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid);

                var EmpResponse = getunit.Content.ReadAsStringAsync().Result;
                if (EmpResponse != null)
                {
                    unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse);
                }
            }
            else
            {
                int HprofileId = -1;
                if (Session["HprofileId"] != null)
                {
                    HprofileId = Convert.ToInt32(Session["HprofileId"]);
                }
                HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Home Contents&SectionUnId=&ProfileUnId=" + HprofileId);

                var EmpResponse = Res.Content.ReadAsStringAsync().Result;
                if (EmpResponse != null)
                {
                    unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse);
                    if (unitdetails.ErrorMessage != null && unitdetails.ErrorMessage.Count() > 0)
                    {
                        bool exists = HomeContent.PolicyInclusions.Exists(p => p.name == "Home Contents");
                        if (exists == true)
                        {
                            List <SessionModel> values = new List <SessionModel>();
                            values = (List <SessionModel>)Session["Policyinclustions"];
                            for (int k = 0; k < values.Count(); k++)
                            {
                                if (values[k].name == "Home Contents" && values[k].UnitId == null && values[k].ProfileId == null)
                                {
                                    values.RemoveAt(k);
                                }
                            }
                            Session["Policyinclustions"] = values;
                        }
                        var errormessage = "First please provide cover for Home Buildings.";
                        if (unitdetails.ErrorMessage.Contains(errormessage))
                        {
                            TempData["Error"] = errormessage;
                            return(RedirectToAction("HomeDescription", "RuralLifeStyle", new { cid = cid, PcId = PcId }));
                        }
                    }
                    if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Home Contents"))
                    {
                        var policyhomelist = Policyincllist.FindAll(p => p.name == "Home Contents").ToList();
                        if (policyhomelist != null && policyhomelist.Count() > 0)
                        {
                            if (Policyincllist.FindAll(p => p.name == "Home Contents").Exists(p => p.UnitId == null))
                            {
                                Policyincllist.FindAll(p => p.name == "Home Contents").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId;
                            }
                            if (Policyincllist.FindAll(p => p.name == "Home Contents").Exists(p => p.ProfileId == null))
                            {
                                Policyincllist.FindAll(p => p.name == "Home Contents").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId;
                            }
                        }
                        else
                        {
                            Policyincllist.FindAll(p => p.name == "Home Contents").First().UnitId    = unitdetails.SectionData.UnId;
                            Policyincllist.FindAll(p => p.name == "Home Contents").First().ProfileId = unitdetails.SectionData.ProfileUnId;
                        }
                        HomeContent.PolicyInclusions = Policyincllist;
                        Session["Policyinclustions"] = Policyincllist;
                    }
                    if (unitdetails != null && unitdetails.SectionData != null)
                    {
                        Session["unId"]      = unitdetails.SectionData.UnId;
                        Session["profileId"] = unitdetails.SectionData.ProfileUnId;
                    }
                }
            }
            if (unitdetails != null)
            {
                if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null)
                {
                    //if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == HomeContent.LocationObj.EiId))
                    //{
                    //    string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == HomeContent.LocationObj.EiId).Select(p => p.Value).FirstOrDefault();
                    //    HomeContent.LocationObj.Location = val;
                    //}
                    if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HomeContent.CosttoreplaceObj.EiId))
                    {
                        string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.CosttoreplaceObj.EiId).Select(p => p.Value).FirstOrDefault();
                        HomeContent.CosttoreplaceObj.Costtoreplaces = val;
                    }
                    if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HomeContent.SuminsuredObj.EiId))
                    {
                        string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.SuminsuredObj.EiId).Select(p => p.Value).FirstOrDefault();
                        if (val != null && !string.IsNullOrEmpty(val))
                        {
                            HomeContent.SuminsuredObj.Suminsured = val;
                        }
                        if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == HomeContent.SuminsuredObj.EiId).Count() > 1)
                        {
                            List <ValueDatas> elmnts = new List <ValueDatas>();
                            var suminsuredList       = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.SuminsuredObj.EiId).Select(p => p.Element.ItId).ToList();
                            for (int i = 0; i < suminsuredList.Count(); i++)
                            {
                                ValueDatas vds = new ValueDatas();
                                vds.Element      = new Elements();
                                vds.Element.ElId = 60287;
                                vds.Element.ItId = suminsuredList[i];
                                vds.Value        = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.SuminsuredObj.EiId && p.Element.ItId == suminsuredList[i]).Select(p => p.Value).FirstOrDefault();
                                elmnts.Add(vds);
                            }
                            HomeContent.SuminsuredObjList = elmnts;
                        }
                    }
                    if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HomeContent.DescriptionObj.EiId))
                    {
                        string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.DescriptionObj.EiId).Select(p => p.Value).FirstOrDefault();
                        if (val != null && !string.IsNullOrEmpty(val))
                        {
                            HomeContent.DescriptionObj.Description = val;
                        }
                        if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == HomeContent.DescriptionObj.EiId).Count() > 1)
                        {
                            List <ValueDatas> elmnts = new List <ValueDatas>();
                            var descriptionList      = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.DescriptionObj.EiId).Select(p => p.Element.ItId).ToList();
                            for (int i = 0; i < descriptionList.Count(); i++)
                            {
                                ValueDatas vds = new ValueDatas();
                                vds.Element      = new Elements();
                                vds.Element.ElId = 60285;
                                vds.Element.ItId = descriptionList[i];
                                vds.Value        = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.DescriptionObj.EiId && p.Element.ItId == descriptionList[i]).Select(p => p.Value).FirstOrDefault();
                                elmnts.Add(vds);
                            }
                            HomeContent.DescriptionObjList = elmnts;
                        }
                    }
                    if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HomeContent.YearclaimObj.EiId))
                    {
                        string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.YearclaimObj.EiId).Select(p => p.Value).FirstOrDefault();
                        HomeContent.YearclaimObj.Yearclaim = val;
                    }
                    if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HomeContent.ExcesspayObj.EiId))
                    {
                        string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HomeContent.ExcesspayObj.EiId).Select(p => p.Value).FirstOrDefault();
                        HomeContent.ExcesspayObj.Excess = val;
                    }
                    if (Session["hombud"] != null)
                    {
                        HomeContent.ExcesspayObj.Excess = "2200";
                    }
                }
                if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null)
                {
                    if (unitdetails.SectionData.AddressData != null)
                    {
                        HomeContent.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode;
                        HomeContent.Pincode            = unitdetails.SectionData.AddressData.Postcode;
                        HomeContent.Sub   = unitdetails.SectionData.AddressData.Suburb;
                        HomeContent.state = unitdetails.SectionData.AddressData.State;
                    }
                }
            }
            if (unitdetails != null && unitdetails.ReferralList != null)
            {
                HomeContent.ReferralList = unitdetails.ReferralList;
                HomeContent.ReferralList.Replace("&nbsp;&nbsp;&nbsp;&nbsp", "");
                HomeContent.Referels = new List <string>();
                string[] delim = { "<br/>" };
                string[] spltd = HomeContent.ReferralList.Split(delim, StringSplitOptions.None);
                if (spltd != null && spltd.Count() > 0)
                {
                    for (int i = 0; i < spltd.Count(); i++)
                    {
                        HomeContent.Referels.Add(spltd[i].Replace("&nbsp;&nbsp;&nbsp;&nbsp", " "));
                    }
                }
            }

            ViewBag.cid = cid;
            if (cid != null)
            {
                HomeContent.CustomerId = cid;
            }
            if (PcId != null && PcId > 0)
            {
                HomeContent.PcId = PcId;
            }
            Session["Controller"] = "HomeContentValuable";
            Session["ActionName"] = "HomeContent";
            return(View(HomeContent));
        }