Ejemplo n.º 1
0
 public JsonResult GetHomeImage(int id)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             var home = touch.HomeImages.SingleOrDefault(A => A.Id == id);
             return(Json(home, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 public JsonResult GetMember(int id)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             var member = touch.TeamMembers.SingleOrDefault(A => A.Id == id);
             return(Json(member, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
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.º 4
0
 public ActionResult AddProfile()
 {
     //throw new Exception();
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 5
0
 public JsonResult GetProject(int id)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             var project = touch.Projects.SingleOrDefault(A => A.Id == id);
             return(Json(project, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 6
0
 public ActionResult EditProfile(int id)
 {
     try
     {
         using (TouchContext touch = new TouchContext())
         {
             var find = touch.CompanyProfiles.FirstOrDefault(a => a.Id == id);
             return(View(find));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
0
        public ActionResult ProjectForm(int?id)
        {
            var model = new ProjectViewModel();

            using (TouchContext db = new TouchContext())
            {
                if (id != null && id > 0)
                {
                    var obj = db.Projects.Include("ProjectImages").FirstOrDefault(a => a.Id == id);
                    model = new ProjectViewModel(obj);
                }
                List <Category> cat     = new List <Category>(db.Categories.ToList());
                SelectList      CatList = new SelectList(cat, "Id", "Name");
                ViewBag.CategoryList = CatList;
            }
            return(View(model));
        }
Ejemplo n.º 13
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.º 14
0
        public ActionResult Projects()
        {
            try
            {
                using (TouchContext db = new TouchContext())
                {
                    List <Category> cat     = new List <Category>(db.Categories.ToList());
                    SelectList      CatList = new SelectList(cat, "Id", "Name");
                    ViewBag.CategoryList = CatList;

                    return(View(db.Projects.Include("SubCategory").ToList()));
                }
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 15
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.º 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 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.º 18
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.º 19
0
 public ActionResult SocialLink()
 {
     try
     {
         using (TouchContext db = new TouchContext())
         {
             if (db.SocialLinks.Any())
             {
                 var existingRow = db.SocialLinks.FirstOrDefault();
                 return(View(existingRow));
             }
             else
             {
                 return(View(new SocialLink()));
             }
         }
     }
     catch (Exception)
     {
     }
     return(View());
 }
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"));
            }
        }