Beispiel #1
0
        public async ValueTask <IActionResult> Get()
        {
            ICollection <Project> model = await _repo.Item()
                                          .Include(x => x.Category)
                                          .Include(x => x.Comments)
                                          .ToListAsync();

            ICollection <Category> categories = await _category.Item().ToListAsync();

            ICollection <BaseProject> projectProjects = model
                                                        .Select(p => p.ConvertToBase(_mapper))
                                                        .Take(10).ToList();

            ICollection <CategoryBase> projectCategories = categories
                                                           .Select(c => c.Convert <Category, CategoryBase>(_mapper))
                                                           .ToList();
            var homeModel = new HomeDTO
            {
                Projects   = projectProjects,
                Categories = projectCategories,
                Total      = model.Count
            };

            return(Ok(homeModel));
        }
Beispiel #2
0
        public static ExposeAccountModel Create(Client client, IList <Claim> claims, HomeDTO defaultHome)
        {
            var dst = new ExposeAccountModel()
            {
                AcceptMailing   = client.AcceptMailing,
                Civility        = client.Civility,
                Country         = client.Country,
                DefaultHomeId   = client.DefaultHomeId,
                Email           = client.Email,
                FirstName       = client.FirstName,
                LastName        = client.LastName,
                Locale          = client.Locale,
                InitManager     = client.InitManager,
                PrincipalPhone  = client.PrincipalPhone,
                SecondaryPhone  = client.SecondaryPhone,
                Timezone        = client.Timezone,
                TutorialManager = client.TutorialManager,
                HomeDefault     = defaultHome
            };

            foreach (var claim in claims)
            {
                dst.Claims.Add(new KeyValuePair <string, string>(claim.Type, claim.Value));
            }
            return(dst);
        }
Beispiel #3
0
        public Response deleteEmployeeData(HomeDTO objHomeDTO)
        {
            var xid = dbcontext.Employee.Where(r => r.Id == objHomeDTO.Id).FirstOrDefault();

            if (xid == null)
            {
                Response response = new Response()
                {
                    Message = "Id does not exist",
                    Status  = false,
                    Data    = null
                };

                return(response);
            }
            else
            {
                Employee xemp = dbcontext.Employee.Where(r => r.Id == xid.Id).FirstOrDefault();
                dbcontext.Employee.Remove(xemp);
                dbcontext.SaveChanges();
                Response response = new Response()
                {
                    Message = "Data is deleted successfully..",
                    Status  = true,
                    Data    = new Array[0]
                };
                return(response);
            }
        }
Beispiel #4
0
        public Response updateEmployeeData(HomeDTO objHomeDTO)
        {
            var xid = dbcontext.Employee.Where(r => r.Id == objHomeDTO.Id).FirstOrDefault();

            if (xid == null)
            {
                Response response = new Response()
                {
                    Message = "Id does not exist",
                    Status  = false,
                    Data    = null
                };

                return(response);
            }
            else
            {
                Employee xemp = dbcontext.Employee.Where(r => r.Id == xid.Id).FirstOrDefault();
                xemp.FirstName = objHomeDTO.FirstName;
                xemp.LastName  = objHomeDTO.LastName;
                xemp.Address   = objHomeDTO.Address;
                xemp.IsStudent = objHomeDTO.IsStudent;
                dbcontext.Employee.Update(xemp);
                dbcontext.SaveChanges();
                Response response = new Response()
                {
                    Message = "Data is updated successfully..",
                    Status  = true,
                    Data    = new Array[0]
                };

                return(response);
            }
        }
Beispiel #5
0
 public async Task <ICollection <ApiHome> > GetHomeDetails(HomeDTO param)
 {
     try
     {
         return(await _homedetails.GetHomeDetails(param));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #6
0
        public IActionResult Get()
        {
            var rv = new HomeDTO
            {
                Users     = _linkGenerator.GetPathByAction(HttpContext, action: "GetAllUsers", controller: "Users"),
                Foods     = "/foods",
                Exercises = "/exercises",
            };

            return(StatusCode(200, rv));
        }
Beispiel #7
0
 public async Task <ActionResult> GetHomeDetails([FromQuery] HomeDTO param)
 {
     try
     {
         return(Ok(await _homeservice.GetHomeDetails(param)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public IActionResult Delete([FromBody] HomeDTO objHomeDTO)
 {
     try
     {
         Response objResponse = objHomeRepository.deleteEmployeeData(objHomeDTO);
         return(Ok(objResponse));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Beispiel #9
0
        public IActionResult Index()
        {
            var model = new HomeDTO();

            if (_loginServices.isAuthen())
            {
                var customer = this._context.Customers.Where(w => w.User.UserName == this.HttpContext.User.Identity.Name).FirstOrDefault();
                if (customer != null)
                {
                    GetCustomerClass(customer, true);
                }
                model.CustomerClass = ViewBag.CustomerClass;
            }
            return(View(model));
        }
Beispiel #10
0
        public async Task <List <ApiHome> > GetHomeDetails(HomeDTO param)
        {
            try
            {
                restClient.ThrowOnDeserializationError = true;

                var request = new RestRequest("Detail/Home", Method.GET, DataFormat.Json);

                request.AddObject(param);

                return(await restClient.GetAsync <List <ApiHome> >(request));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #11
0
        public async Task <IHttpActionResult> GetAccount()
        {
            int    idUser         = User.Identity.GetUserId <int>();
            Client ClientSelected = await Manager.FindUserByIdWithPhoneNumberAsync(idUser);

            HomeDTO DefaultHome = null;

            try
            {
                _HomeService.SetModelState(ModelState);
                DefaultHome = _HomeService.DoGetDefaultHome(ClientSelected);
            }
            catch (ManahostValidationException)
            {
            }
            return(Ok(Factory.Create(ClientSelected, await Manager.GetClaimsAsync(idUser), DefaultHome)));
        }
        public IActionResult Index()
        {
            var list = _repository.GetAll();
            //使用DTO进行转换
            var vms = list.Select(x => new StudentInfoDTO
            {
                Id   = x.stuId,
                Name = $"{x.stuFirstName}{x.stuLastName}",
                Age  = DateTime.Now.Subtract(x.stuBirthDate).Days / 365
            });
            var vm = new HomeDTO
            {
                Students = vms
            };

            return(View(vm));
        }
Beispiel #13
0
        public ActionResult Home()
        {
            IList <Edge> edges;
            IList <City> cities2;

            using (var context = new TLContext())
            {
                edges   = context.GetAllEdges();
                cities2 = context.GetCities().ToList();
            }
            var cities    = MappingService.GetCities();
            var dtoCities = new List <CityDTO>();

            foreach (var city in cities)
            {
                dtoCities.Add(new CityDTO()
                {
                    Id   = city.ID,
                    Name = city.Name
                });
            }

            var parcelTypes    = MappingService.GetParcelTypes();
            var dtoParcelTypes = new List <ParcelTypeDTO>();

            foreach (var parcelType in parcelTypes)
            {
                dtoParcelTypes.Add(new ParcelTypeDTO()
                {
                    Id   = parcelType.ID,
                    Name = parcelType.Name
                });
            }

            var model = new HomeDTO
            {
                SourceCitites      = dtoCities,
                DestinationCitites = dtoCities,
                ParcelTypes        = dtoParcelTypes
            };

            return(View(model));
        }
Beispiel #14
0
        public HomeDTO Initialize()
        {
            SongBL  songBL   = new SongBL();
            HomeDTO homeDTO  = new HomeDTO();
            UserBL  userBL   = new UserBL();
            string  userName = GetUserName(songBL);

            if (!userBL.CheckUser(userName))
            {
                // Insert new user
                userBL.InsertUser(userName);
            }
            else
            {
                homeDTO.UserDefaultList = songBL.GetDefaultList(userName);
            }

            homeDTO.TopFPT   = songBL.SelectTopFptSong();
            homeDTO.TopWorld = songBL.SelectTopWorldSong();
            return(homeDTO);
        }
Beispiel #15
0
        public async Task <ActionResult <HomeDTO> > Get()
        {
            var top   = 6;
            var today = DateTime.Today;

            var upcomingReleases = await context.Movies
                                   .Where(x => x.ReleaseDate > today)
                                   .OrderBy(x => x.ReleaseDate)
                                   .Take(top)
                                   .ToListAsync();

            var inTheaters = await context.Movies
                             .Where(x => x.InTheaters)
                             .OrderBy(x => x.ReleaseDate)
                             .Take(top)
                             .ToListAsync();

            var homeDTO = new HomeDTO();

            homeDTO.UpcomingReleases = mapper.Map <List <MovieDTO> >(upcomingReleases);
            homeDTO.InTheaters       = mapper.Map <List <MovieDTO> >(inTheaters);
            return(homeDTO);
        }
Beispiel #16
0
        public Response insertEmployeeData(HomeDTO objHomeDTO)
        {
            Employee objEmployee = new Employee()
            {
                FirstName = objHomeDTO.FirstName,
                LastName  = objHomeDTO.LastName,
                Address   = objHomeDTO.Address,
                IsStudent = objHomeDTO.IsStudent,
                CreatedAt = System.DateTime.Now,
                UpdatedAt = System.DateTime.Now
            };

            dbcontext.Employee.Add(objEmployee);
            dbcontext.SaveChanges();
            Response response = new Response()
            {
                Message = "Data is inserted successfully..",
                Status  = true,
                Data    = new Array[0]
            };

            return(response);
        }
 public void Delete(HomeDTO entidad)
 {
     _homeRepository.Delete(Mapper.Map <HomeDTO, Home>(entidad));
     _homeRepository.UnitOfWork.Complete();
 }
Beispiel #18
0
 public HomeDTO Post([FromBody] HomeDTO Home)
 {
     return(HomeService.PrePostDTO(ModelState, currentClient, Home));
 }
Beispiel #19
0
 public IHttpActionResult Put([FromUri] int id, [FromBody] HomeDTO Home)
 {
     HomeService.PrePutDTO(ModelState, currentClient, id, Home);
     return(Ok());
 }
Beispiel #20
0
        public ActionResult Index(int?page)
        {
            string sort     = CheckParameter("sort");
            string search   = CheckParameter("Search");
            string max      = CheckParameter("Max");
            string min      = CheckParameter("Min");
            var    externs  = CheckAndConvertParameter("Externs");
            var    interns  = CheckAndConvertParameter("Interns");
            var    shops    = CheckAndConvertParameter("Shops");
            var    touches  = CheckAndConvertParameter("Touches");
            var    os       = CheckAndConvertParameter("OS");
            var    ram      = CheckAndConvertParameter("Ram");
            var    battery  = CheckAndConvertParameter("Battery");
            var    fronts   = CheckAndConvertParameter("Fronts");
            var    backs    = CheckAndConvertParameter("Backs");
            var    FMRadio  = CheckParameter("FMRadio");
            var    HDVoice  = CheckParameter("HDVoice");
            var    Port35mm = CheckParameter("Port35mm");

            double.TryParse(max, out double maxDouble);
            double.TryParse(min, out double minDouble);

            ViewBag.Search   = Request.QueryString["search"];
            ViewBag.Max      = Request.QueryString["max"];
            ViewBag.Min      = Request.QueryString["min"];
            ViewBag.Externs  = Request.QueryString["externs"];
            ViewBag.Interns  = Request.QueryString["interns"];
            ViewBag.Shops    = Request.QueryString["shops"];
            ViewBag.Touches  = Request.QueryString["touches"];
            ViewBag.OS       = Request.QueryString["os"];
            ViewBag.Ram      = Request.QueryString["ram"];
            ViewBag.Battery  = Request.QueryString["battery"];
            ViewBag.Fronts   = Request.QueryString["fronts"];
            ViewBag.Backs    = Request.QueryString["backs"];
            ViewBag.FMRadio  = Request.QueryString["fmradio"];
            ViewBag.HDVoice  = Request.QueryString["hdvoice"];
            ViewBag.Port35mm = Request.QueryString["port35mm"];
            ViewBag.Sort     = Request.QueryString["sort"];

            IEnumerable <ShopMobilesM> shopMobiles = shopMobilesService.FindAll().Where(x =>
                                                                                        x.MobilesLeft > 0 &&
                                                                                        (search != null ? mobileService.FindById(x.MobileId).Name.ToLower().Contains(search.ToLower()) : true) &&
                                                                                        (maxDouble != 0 ? x.Price <= maxDouble : true) &&
                                                                                        (minDouble != 0 ? x.Price >= minDouble : true) &&
                                                                                        (externs != null ? externs.Contains(mobileService.FindById(x.MobileId).ExternMemoryId.ToString()) : true) &&
                                                                                        (interns != null ? interns.Contains(mobileService.FindById(x.MobileId).InternMemoryId.ToString()) : true) &&
                                                                                        (shops != null ? shops.Contains(x.ShopId.ToString()) : true) &&
                                                                                        (touches != null ? (touches.Contains("yes") && mobileService.FindById(x.MobileId).Touch) || (touches.Contains("no") && !mobileService.FindById(x.MobileId).Touch) : true) &&
                                                                                        (os != null ? os.Contains(mobileService.FindById(x.MobileId).OsId.ToString()) : true) &&
                                                                                        (ram != null ? ram.Contains(mobileService.FindById(x.MobileId).RamId.ToString()) : true) &&
                                                                                        (battery != null ? battery.Contains(mobileService.FindById(x.MobileId).BatteryId.ToString()) : true) &&
                                                                                        (fronts != null ? fronts.Contains(mobileService.FindById(x.MobileId).FrontCameraId.ToString()) : true) &&
                                                                                        (backs != null ? backs.Contains(mobileService.FindById(x.MobileId).BackCameraId.ToString()) : true) &&
                                                                                        (FMRadio != null ? FMRadio.Contains("True") && mobileService.FindById(x.MobileId).FMRadio : true) &&
                                                                                        (HDVoice != null ? HDVoice.Contains("True") && mobileService.FindById(x.MobileId).HDVoice : true) &&
                                                                                        (Port35mm != null ? Port35mm.Contains("True") && mobileService.FindById(x.MobileId).Port35mm : true)
                                                                                        );

            if (sort == null || sort == "1")
            {
                shopMobiles = shopMobiles.OrderBy(x => x.Price);
            }
            else
            {
                shopMobiles = shopMobiles.OrderByDescending(x => x.Price);
            }
            List <HomeMobile> homeMobiles = new List <HomeMobile>();

            foreach (ShopMobilesM sm in shopMobiles)
            {
                List <string> images = new List <string>();
                foreach (ImagesM img in imageService.FindByMobile(sm.MobileId))
                {
                    images.Add(Convert.ToBase64String(img.ImageBinary));
                }

                homeMobiles.Add(new HomeMobile()
                {
                    Id       = sm.Id,
                    Name     = mobileService.FindById(sm.MobileId).Name,
                    Price    = sm.Price,
                    ShopId   = sm.ShopId,
                    ShopName = shopService.FindById(sm.ShopId).ShopName,
                    Images   = images,
                    MobileId = sm.MobileId,
                });
            }

            var minMax = shopMobilesService.FindAll().OrderBy(x => x.Price).ToList();

            DropDowns dropDowns = new DropDowns()
            {
                Batteries        = batteryService.FindAll(),
                Cameras          = cameraService.FindAll(),
                Memories         = memoryService.FindAll(),
                Shops            = shopService.FindAll(),
                OperativeSystems = operativeSystemService.FindAll(),
                Rams             = ramService.FindAll(),
                MaxPrice         = minMax.Count > 0 ? minMax[minMax.Count - 1].Price : 0,
                MinPrice         = minMax.Count > 0 ? minMax[0].Price : 0,
            };
            HomeDTO homeDTO = new HomeDTO()
            {
                Drops   = dropDowns,
                Mobiles = homeMobiles.ToPagedList(page ?? 1, 3),
            };

            return(View(homeDTO));
        }
Beispiel #21
0
 public async Task UpdateHome([FromBody]  HomeDTO dto)
 {
     var home = _mapper.Map <Home>(dto);
     await _repo.UpdateHome(home);
 }
Beispiel #22
0
 public void Add(HomeDTO request)
 {
     _homeService.Add(request);
 }
Beispiel #23
0
        public async Task <ActionResult> Edit(HomeDTO home, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(" ", "duzgun yazilmayib metin !!!!");
                return(View(home));
            }
            int     id  = home.Id;
            HomeDTO dto = await db.Homes.FirstOrDefaultAsync(x => x.Id == id);

            dto.HeaderTitle = home.HeaderTitle;
            dto.HeaderPrice = home.HeaderPrice;
            await db.SaveChangesAsync();

            #region imageUpload

            if (file != null && file.ContentLength > 0)
            {
                // Get extension
                string ext = file.ContentType.ToLower();

                // Verify extension
                if (ext != "image/jpg" &&
                    ext != "image/jpeg" &&
                    ext != "image/pjpeg" &&
                    ext != "image/gif" &&
                    ext != "image/x-png" &&
                    ext != "image/png")
                {
                    ModelState.AddModelError("", "The image was not uploaded - wrong image extension.");
                    return(View(home));
                }

                // Set uplpad directory paths
                var originalDirectory = new DirectoryInfo(string.Format("{0}Content\\img", Server.MapPath(@"\")));

                var pathString1 = Path.Combine(originalDirectory.ToString(), "slider\\" + id.ToString());
                var pathString2 = Path.Combine(originalDirectory.ToString(), "slider\\" + id.ToString() + "\\thumbs");

                if (!Directory.Exists(pathString1))
                {
                    Directory.CreateDirectory(pathString1);
                }
                if (!Directory.Exists(pathString2))
                {
                    Directory.CreateDirectory(pathString2);
                }
                // Delete files from directories

                DirectoryInfo di1 = new DirectoryInfo(pathString1);
                DirectoryInfo di2 = new DirectoryInfo(pathString2);

                foreach (FileInfo file2 in di1.GetFiles())
                {
                    file2.Delete();
                }
                foreach (FileInfo file3 in di2.GetFiles())
                {
                    file3.Delete();
                }
                if (di1.GetFiles() == null)
                {
                    ModelState.AddModelError("Image", "Sekilin yolu movcud deyil");
                }
                //foreach (FileInfo file3 in di2.GetFiles())
                //    file3.Delete();

                // Save image name

                string imageName = file.FileName;


                HomeDTO dtoBase = await db.Homes.FindAsync(id);

                dtoBase.Image = imageName;

                await db.SaveChangesAsync();


                // Save original and thumb images

                var path  = string.Format("{0}\\{1}", pathString1, imageName);
                var path2 = string.Format("{0}\\{1}", pathString2, imageName);

                file.SaveAs(path);

                WebImage img = new WebImage(file.InputStream);
                img.Resize(200, 200);
                img.Save(path2);
            }

            #endregion
            TempData["SM"] = "You have edited the home page!";

            return(RedirectToAction("Index"));
        }