Ejemplo n.º 1
0
 public ActionResult CreatHome(HomeImageViewModel Input)
 {
     try
     {
         var      Date = DateTime.Now.ToFileTimeUtc();
         String[] Arr  = Input.PicturePath.FileName.Split('.');
         if (Input.PicturePath != null)
         {
             Input.PicturePath.SaveAs(HttpContext.
                                      Server.MapPath("~/Images/backgrounds/") + Arr[0] + Date + "_L." + Arr[1]);
             Bitmap b            = new Bitmap(Input.PicturePath.InputStream);
             var    resizedImage = Helpers.ImageResizeHelper.ResizeBitmap(b, 100, 100);
             resizedImage.Save(HttpContext.
                               Server.MapPath("~/Images/backgrounds/SmallBackGround/") + Arr[0] + Date + "_S." + Arr[1]);
         }
         using (TouchContext touch = new TouchContext())
         {
             touch.HomeImages.Add
                 (new HomeImage()
             {
                 Title       = Input.Title,
                 Description = Input.Description,
                 Extention   = Arr[1],
                 PicturePath = Arr[0] + Date,
                 IsActive    = Input.IsActive
             });
             touch.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 2
0
 public ActionResult SaveHomeImages(HomeImageViewModel Input)
 {
     try
     {
         var Date = DateTime.Now.ToFileTimeUtc();
         using (TouchContext touch = new TouchContext())
         {
             var obj = touch.HomeImages.Where(a => a.Id == Input.Id).FirstOrDefault();
             obj.Title       = Input.Title;
             obj.Description = Input.Description;
             obj.IsActive    = Input.IsActive;
             if (Input.PicturePath != null)
             {
                 string[] Arr = Input.PicturePath.FileName.Split('.');
                 Input.PicturePath.SaveAs(HttpContext.Server.MapPath("~/Images/backgrounds/") + Arr[0] + Date + "_L." + Arr[1]);
                 Bitmap b            = new Bitmap(Input.PicturePath.InputStream);
                 var    resizedImage = Helpers.ImageResizeHelper.ResizeBitmap(b, 100, 100);
                 resizedImage.Save(HttpContext.Server.MapPath("~/Images/backgrounds/SmallBackGround/") + Arr[0] + Date + "_S." + Arr[1]);
                 obj.PicturePath = Arr[0] + Date;
                 obj.Extention   = Arr[1];
             }
             touch.Entry(obj).State = EntityState.Modified;
             touch.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 3
0
        public ActionResult AddProject(ProjectViewModel Input)
        {
            try
            {
                var Date = DateTime.Now.ToFileTimeUtc();
                if (Input.LogoPath != null)
                {
                    var resizedImage = Helpers.ImageResizeHelper.FixedSize(Image.FromStream(Input.LogoPath.InputStream), 100, 100);
                    resizedImage.Save(HttpContext.
                                      Server.MapPath("~/Images/logo/") + Date);
                }

                using (TouchContext touch = new TouchContext())
                {
                    touch.Projects.Add
                        (new Project()
                    {
                        Name        = Input.Name,
                        Location    = Input.Location,
                        Area        = Input.Area,
                        Client      = Input.Client,
                        LogoPath    = Input.LogoPath.FileName + Date,
                        Category    = Input.Category,
                        SubCategory = Input.SubCategory,
                        IsActive    = Input.IsActive
                    });
                    touch.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
 public ActionResult addSubCategory(SubCategory input)
 {
     using (TouchContext db = new TouchContext())
     {
         db.SubCategories.Add(input);
         db.SaveChanges();
     }
     return(Json(input, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 5
0
 public ActionResult AddCareer(CareerInfo career)
 {
     using (TouchContext db = new TouchContext())
     {
         //db.CareerInformation.Add(career);
         //var obj = db.CareerInformation.Where(a => a.Id == career.Id).FirstOrDefault();
         db.Entry(career).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("JobApplication"));
     }
 }
Ejemplo n.º 6
0
 public ActionResult DeleteSubCategory(int id)
 {
     using (TouchContext db = new TouchContext())
     {
         var del = db.SubCategories.FirstOrDefault(a => a.Id == id);
         db.SubCategories.Remove(del);
         db.SaveChanges();
         var list = db.SubCategories.ToList();
         return(Json(list, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 7
0
 public ActionResult addCategory(Category input)
 {
     using (TouchContext db = new TouchContext())
     {
         if (!string.IsNullOrEmpty(input.Name))
         {
             db.Categories.Add(input);
             db.SaveChanges();
         }
     }
     return(Json(input, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 8
0
 public ActionResult ContactUs(ContactUs Input)
 {
     try
     {
         if (Input.Id == 0)
         {
             Touch.ContactUs.Add(Input);
             Touch.SaveChanges();
         }
         else
         {
             Touch.Entry(Input).State = EntityState.Modified;
             Touch.SaveChanges();
         }
         return(view(Input));
     }
     catch (Exception ex)
     {
         throw;
     }
     return(Redirect("~/Admine/Index"));
 }
Ejemplo n.º 9
0
 public ActionResult Index(ContactViewModel input)
 {
     using (TouchContext db = new TouchContext())
     {
         input.Message.SendDate = DateTime.Now;
         input.Message.IsRead   = false;
         db.ContactUsMessages.Add(input.Message);
         db.SaveChanges();
         var result = new ContactViewModel()
         {
             ContactUs = db.ContactUs.FirstOrDefault()
         };
         return(View(result));
     }
 }
Ejemplo n.º 10
0
 public ActionResult AddVip(VipService Add)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             touch.VipServices.Add(Add);
             touch.SaveChanges();
             return(RedirectToAction("vip"));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 11
0
 public ActionResult AddProfile(CompanyProfile Add)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             touch.CompanyProfiles.Add(Add);
             touch.SaveChanges();
             return(Redirect("~/Admin/CompanyProfile"));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 12
0
 public ActionResult EditProfile(CompanyProfile input)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             touch.Entry(input).State = EntityState.Modified;
             touch.SaveChanges();
             return(Redirect("~/Admin/CompanyProfile"));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 13
0
 public ActionResult Editvip(VipService input)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             touch.Entry(input).State = EntityState.Modified;
             touch.SaveChanges();
             return(RedirectToAction("vip"));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 14
0
 public ActionResult DeleteProfile(int id)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             var del = touch.CompanyProfiles.FirstOrDefault(a => a.Id == id);
             touch.CompanyProfiles.Remove(del);
             touch.SaveChanges();
         }
     }
     catch (Exception)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 15
0
 public ActionResult ReadMessage(int id)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             var View = touch.ContactUsMessages.FirstOrDefault(a => a.Id == id);
             View.IsRead             = true;
             touch.Entry(View).State = EntityState.Modified;
             touch.SaveChanges();
             return(Json(View, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 16
0
 public ActionResult CreatMember(TeamMemberViewModel Input)
 {
     try
     {
         var      Date = DateTime.Now.ToFileTimeUtc();
         String[] Arr  = Input.PicturePath.FileName.Split('.');
         String[] Arry = Input.CvPath.FileName.Split('.');
         if (Input.PicturePath != null && Input.CvPath != null)
         {
             Input.PicturePath.SaveAs(HttpContext.
                                      Server.MapPath("~/Images/Profile/") + Arr[0] + Date + "_L." + Arr[1]);
             if (Arry[1] == "pdf")
             {
                 Input.CvPath.SaveAs(HttpContext.Server.MapPath("~/File/MemberCv/") + Input.CvPath.FileName);
             }
             Bitmap b            = new Bitmap(Input.PicturePath.InputStream);
             var    resizedImage = Helpers.ImageResizeHelper.ResizeBitmap(b, 100, 100);
             resizedImage.Save(HttpContext.
                               Server.MapPath("~/Images/Profile/Display/") + Arr[0] + Date + "_S." + Arr[1]);
         }
         using (TouchContext touch = new TouchContext())
         {
             touch.TeamMembers.Add
                 (new TeamMember()
             {
                 Name        = Input.Name,
                 Position    = Input.Position,
                 Details     = Input.Details,
                 Extention   = Arr[1],
                 PicturePath = Arr[0] + Date,
                 CvPath      = Input.CvPath.FileName,
                 Email       = Input.Email,
                 Phone       = Input.Phone
             });
             touch.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 17
0
        public ActionResult DeleteProjectImage(int id)
        {
            try
            {
                using (TouchContext db = new TouchContext())
                {
                    var image = db.ProjectsImages.Single(e => e.Id == id);
                    db.ProjectsImages.Remove(image);
                    System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/Projects/Temp"), image.FileName));
                    db.SaveChanges();

                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 18
0
        public ActionResult Index(CareersViewModel input)
        {
            using (TouchContext db = new TouchContext())
            {
                string extension = Request.Files[0]?.FileName.Split('.').Last();
                string fileName  = Request.Files[0]?.FileName.Split('.').First();
                input.Application.CvPath = fileName + DateTime.Now.ToFileTime() + "." + extension;
                var    file          = Request.Files[0];
                string savedFileName = Path.Combine(Server.MapPath("~/File/JobCv"), Path.GetFileName(input.Application.CvPath));
                file.SaveAs(savedFileName); // Save the file
                db.JobApplication.Add(input.Application);
                db.SaveChanges();
                input.Application = new JobApplication();
                input.Info        = db.CareerInformation.FirstOrDefault();
                input.IsSent      = true;
            }


            return(View(input));
        }
Ejemplo n.º 19
0
        public ActionResult Savemember(TeamMemberViewModel Input)
        {
            try
            {
                using (TouchContext touch = new TouchContext())
                {
                    var obj = touch.TeamMembers.Where(a => a.Id == Input.Id).FirstOrDefault();
                    obj.Id       = Input.Id;
                    obj.Name     = Input.Name;
                    obj.Position = Input.Position;
                    obj.Details  = Input.Details;
                    obj.Email    = Input.Email;
                    obj.Phone    = Input.Phone;

                    var Date = DateTime.Now.ToFileTimeUtc();
                    if (Input.PicturePath != null)
                    {
                        string[] Arr = Input.PicturePath.FileName.Split('.');
                        Input.PicturePath.SaveAs(HttpContext.Server.MapPath("~/Images/Profile/") + Arr[0] + Date + "_L." + Arr[1]);
                        Bitmap b            = new Bitmap(Input.PicturePath.InputStream);
                        var    resizedImage = Helpers.ImageResizeHelper.ResizeBitmap(b, 100, 100);
                        resizedImage.Save(HttpContext.Server.MapPath("~/Images/Profile/Display/") + Arr[0] + Date + "_S." + Arr[1]);
                        obj.PicturePath = Arr[0] + Date;
                        obj.Extention   = Arr[1];
                    }
                    if (Input.CvPath != null)
                    {
                        Input.CvPath.SaveAs(HttpContext.Server.MapPath("~/File/MemberCv/") + Input.CvPath.FileName);
                        obj.CvPath = Input.CvPath.FileName;
                    }
                    touch.Entry(obj).State = EntityState.Modified;
                    touch.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 20
0
 public HttpStatusCodeResult SocialLink(SocialLink input)
 {
     try
     {
         using (TouchContext db = new TouchContext())
         {
             if (input.Id > 0)
             {
                 db.Entry(input).State = EntityState.Modified;
             }
             else
             {
                 db.SocialLinks.Add(input);
             }
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
         // throw;
     }
     return(new HttpStatusCodeResult(HttpStatusCode.OK));
 }
Ejemplo n.º 21
0
        public ActionResult ProjectForm(ProjectViewModel input, string imagesNames)
        {
            using (TouchContext db = new TouchContext())
            {
                var      Date = DateTime.Now.ToFileTimeUtc();
                string[] arr  = input.LogoPath?.FileName.Split('.');
                Project  project;
                if (input.Id == 0)
                {
                    project = new Project()
                    {
                        Area          = input.Area,
                        Client        = input.Client,
                        Location      = input.Location,
                        Name          = input.Name,
                        IsActive      = input.IsActive,
                        CategoryId    = input.CategoryId,
                        SubCategoryId = input.SubCategoryId,
                        //LogoPath = input.LogoPath.FileName.Split('.').First() + Date+"."+ input.LogoPath.FileName.Split('.').Last()
                    };

                    if (arr != null)
                    {
                        project.LogoPath = arr[0] + Date + "." + arr[1];
                    }
                    db.Projects.Add(project);
                    db.SaveChanges();
                }
                else
                {
                    project               = db.Projects.Single(e => e.Id == input.Id);
                    project.Area          = input.Area;
                    project.Client        = input.Client;
                    project.Location      = input.Location;
                    project.Name          = input.Name;
                    project.IsActive      = input.IsActive;
                    project.CategoryId    = input.CategoryId;
                    project.SubCategoryId = input.SubCategoryId;
                    if (input.LogoPath != null)
                    {
                        project.LogoPath = project.LogoPath = arr[0] + Date + "." + arr[1];
                    }
                }
                if (input.LogoPath != null)
                {
                    var resizedImage = Helpers.ImageResizeHelper.ResizeBitmap(new Bitmap(input.LogoPath.InputStream), 100, 100);
                    resizedImage.Save(HttpContext.Server.MapPath("~/Images/logo/") + arr[0] + Date + "." + arr[1]);
                }
                var selectedImagesNames = imagesNames.Split(',');
                if (selectedImagesNames.Length > 0)
                {
                    List <ProjectImage> images = new List <ProjectImage>();
                    foreach (var item in selectedImagesNames)
                    {
                        if (System.IO.File.Exists(Path.Combine(Server.MapPath("~/Images/Projects/Temp"), item)))
                        {
                            var file = item.Split('.').First() + Date + "." + item.Split('.').Last();
                            System.IO.File.Copy(Path.Combine(Server.MapPath("~/Images/Projects/Temp"), item), Path.Combine(Server.MapPath("~/Images/Projects/"), file));
                            System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/Projects/Temp"), item));
                            images.Add(new ProjectImage()
                            {
                                FileName = file, ProjectId = project.Id
                            });
                        }
                    }
                    db.ProjectsImages.AddRange(images);
                    db.SaveChanges();
                }
                System.IO.DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/Images/Projects/Temp"));
                foreach (FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
                List <Category> cat     = new List <Category>(db.Categories.ToList());
                SelectList      CatList = new SelectList(cat, "Id", "Name");
                ViewBag.CategoryList = CatList;
                return(Redirect("~/Admin/Projects"));
            }
        }