Exemplo n.º 1
0
        public ActionResult EditOurTeam()
        {
            ImageHelperNew.DestroyImageCashAndSession(175, 175);
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (RouteData.Values["id"] != null)
            {
                int  nid      = 0;
                bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                if (isnumber)
                {
                    OurTeam editOurTeam = OurTeamManager.GetOurTeamById(nid);
                    return(View(editOurTeam));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult AddOurTeam(OurTeam OurTeammodel, HttpPostedFileBase uploadfile, string txtdate)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    OurTeammodel.Image = "/Content/images/userfiles/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                else
                {
                    OurTeammodel.Image = "/Content/images/front/noimage.jpeg";
                }

                OurTeammodel.PageSlug    = Utility.SetPagePlug(OurTeammodel.Name);
                OurTeammodel.TimeCreated = Utility.ControlDateTime(txtdate);
                ViewBag.ProcessMessage   = OurTeamManager.AddOurTeam(OurTeammodel);
                ModelState.Clear();
                return(View());
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        public IActionResult Create(IFormFile image, OurTeam ourTeam)
        {
            ViewData["Departments"] = new SelectList(_work.Departments.GetAll(), "Id", "Name");
            ViewData["Designation"] = new SelectList(_work.Designations.GetAll(), "Id", "Name");
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    var fileName = ContentDispositionHeaderValue.Parse(image.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty);
                    var path     = _imagePath.GetImagePath(fileName, "OurTeam", ourTeam.Name.Replace(" ", string.Empty));
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        image.CopyTo(stream);
                    }
                    ourTeam.Image = _imagePath.GetImagePathForDb(path);
                }

                _work.OurTeams.Add(ourTeam);
                _work.Complete();
                ModelState.Clear();
                ourTeam = new OurTeam();
                return(PartialView("_Create", ourTeam));
            }

            return(PartialView("_Create", ourTeam));
        }
        public ActionResult Edit(OurTeam outTeam, HttpPostedFileBase OurTeamImage)
        {
            if (ModelState.IsValid)
            {
                #region Upload Image
                if (OurTeamImage != null)
                {
                    if (System.IO.File.Exists(Server.MapPath("/Files/OurTeamImages/" + outTeam.Image)))
                    {
                        System.IO.File.Delete(Server.MapPath("/Files/OurTeamImages/" + outTeam.Image));
                    }
                    // Saving Temp Image
                    var newFileName = Guid.NewGuid() + Path.GetExtension(OurTeamImage.FileName);
                    OurTeamImage.SaveAs(Server.MapPath("/Files/OurTeamImages/Temp/" + newFileName));
                    // Resize Image
                    ImageResizer image = new ImageResizer(370, 435, true);
                    image.Resize(Server.MapPath("/Files/OurTeamImages/Temp/" + newFileName),
                                 Server.MapPath("/Files/OurTeamImages/" + newFileName));

                    // Deleting Temp Image
                    System.IO.File.Delete(Server.MapPath("/Files/OurTeamImages/Temp/" + newFileName));
                    outTeam.Image = newFileName;
                }
                #endregion

                _repo.Update(outTeam);
                return(RedirectToAction("Index"));
            }
            return(View(outTeam));
        }
Exemplo n.º 5
0
 public IActionResult Edit(IFormFile image, OurTeam ourTeam)
 {
     if (ModelState.IsValid)
     {
         if (image != null)
         {
             var fileName = ContentDispositionHeaderValue.Parse(image.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty);
             var path     = _imagePath.GetImagePath(fileName, "OurTeam", ourTeam.Name.Replace(" ", string.Empty));
             using (var stream = new FileStream(path, FileMode.Create))
             {
                 image.CopyTo(stream);
             }
             ourTeam.Image = _imagePath.GetImagePathForDb(path);
         }
         if (image == null)
         {
             var teamImage = _work.OurTeams.Get(ourTeam.Id);
             teamImage.Name          = ourTeam.Name;
             teamImage.DepartmentId  = ourTeam.DepartmentId;
             teamImage.DesignationId = ourTeam.DesignationId;
             teamImage.Description   = ourTeam.Description;
             teamImage.Facebook      = ourTeam.Facebook;
             teamImage.Twitter       = ourTeam.Twitter;
             _work.OurTeams.Update(teamImage);
             _work.Complete();
             return(PartialView("_Edit", ourTeam));
         }
         _work.OurTeams.Update(ourTeam);
         _work.Complete();
         return(PartialView("_Edit", ourTeam));
     }
     return(PartialView("_Edit", ourTeam));
 }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Id,Image,Fullname,Job,Email,SocialID")] OurTeam ourTeam, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image == null)
                {
                    return(RedirectToAction("Create", "OurTeams"));
                }
                if (Extension.CheckImg(Image, Extension.MAxfileSize))
                {
                    try
                    {
                        ourTeam.Image = Extension.SaveImg(Image, "~/Public2/images/team");
                    }
                    catch
                    {
                        return(View(ourTeam));
                    }
                }
                else
                {
                    return(View(ourTeam));
                }
                db.OurTeams.Add(ourTeam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SocialID = new SelectList(db.Socials, "Id", "Link1", ourTeam.SocialID);
            return(View(ourTeam));
        }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "Id,Image,Fullname,Job,Email,SocialID")] OurTeam ourTeam, HttpPostedFileBase Image, string fileadi)
 {
     if (ModelState.IsValid)
     {
         if (Image != null)
         {
             if (Extension.CheckImg(Image, Extension.MAxfileSize))
             {
                 try
                 {
                     ourTeam.Image = Extension.SaveImg(Image, "~/Public2/images/team");
                 }
                 catch
                 {
                     return(View(ourTeam));
                 }
             }
             else
             {
                 return(View(ourTeam));
             }
         }
         else
         {
             ourTeam.Image = fileadi;
         }
         db.Entry(ourTeam).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SocialID = new SelectList(db.Socials, "Id", "Link1", ourTeam.SocialID);
     return(View(ourTeam));
 }
Exemplo n.º 8
0
        public IActionResult Edit(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (id == null)
            {
                return(View("Error"));
            }
            OurTeam category  = _context.OurTeam.Find(id);
            var     viewModel = new CreateTeamVM
            {
                FullNameAZ   = category.OurTeamLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "az").FullName,
                FullNameEN   = category.OurTeamLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "en").FullName,
                FullNameRU   = category.OurTeamLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "ru").FullName,
                ProfessionAZ = category.OurTeamLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "az").Profession,
                ProfessionEN = category.OurTeamLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "en").Profession,
                ProfessionRU = category.OurTeamLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "ru").Profession,
            };

            return(View(viewModel));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> DeletePost(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }
            OurTeam category = await _context.OurTeam.FindAsync(id);

            string computerPhoto = Path.Combine(_env.WebRootPath, "images", category.PhotoURL);

            if (System.IO.File.Exists(computerPhoto))
            {
                System.IO.File.Delete(computerPhoto);
            }

            _context.OurTeam.Remove(category);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create(OurTeam worker)
        {
            if (worker.Photo == null)
            {
                ModelState.AddModelError("", "Qaqi Shekil Sech ginen");
                return(View());
            }
            if (!worker.Photo.IsImage())
            {
                ModelState.AddModelError("", "Shekil formati sechin");
                return(View());
            }
            if (worker.Photo.MaxLength(1500))
            {
                ModelState.AddModelError("", "Shekilin olchusu max 1500kb ola biler");
            }
            OurTeam team = worker;

            team.Image = await worker.Photo.SaveImage(_env.WebRootPath, "img/OurTeam");

            await _db.OurTeams.AddAsync(team);

            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
 public static bool AddOurTeam(OurTeam record)
 {
     using (MainContext db = new MainContext())
     {
         try
         {
             if (!record.TimeCreated.HasValue)
             {
                 record.TimeCreated = DateTime.Now;
             }
             record.Deleted   = false;
             record.Online    = true;
             record.SortOrder = 9999;
             db.OurTeam.Add(record);
             db.SaveChanges();
             LogtrackManager logkeeper = new LogtrackManager();
             logkeeper.LogDate    = DateTime.Now;
             logkeeper.LogProcess = EnumLogType.Haber.ToString();
             logkeeper.Message    = "Ekibimiz kaydı eklendi";
             logkeeper.User       = HttpContext.Current.User.Identity.Name;
             logkeeper.Data       = record.Name;
             logkeeper.AddInfoLog(logger);
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Exemplo n.º 12
0
        public async Task <IActionResult> EditOurTeam(TeamEditViewModel teamView)
        {
            if (teamView.TeamImage != null)
            {
                using (var memoryStream = new MemoryStream())
                {
                    await teamView.TeamImage.CopyToAsync(memoryStream);

                    teamView.Team.Image         = memoryStream.ToArray();
                    teamView.Team.ImageMimeType = teamView.TeamImage.ContentType;
                }
            }
            if (ModelState.IsValid)
            {
                var category = new OurTeam
                {
                    Name        = teamView.Team.Name,
                    Description = teamView.Team.Description,
                    Position    = teamView.Team.Position,
                    Image       = teamView.Team.Image
                };

                teamRepository.SaveTeam(teamView.Team);
                TempData["message"] = $"{teamView.Team.Name} has been saved";
                return(RedirectToAction("InformationList"));
            }
            else
            {
                // there is something wrong with the data values
                return(View(teamView));
            }
        }
Exemplo n.º 13
0
 private AgentActivityData RemoveTile(Coordinate coordinate)
 {
     if (Calc.Field[coordinate].IsTileOn[OurTeam.Opponent()])
     {
         return(new AgentActivityData(AgentStatusCode.RequestRemovementOpponentTile, coordinate));
     }
     return(new AgentActivityData(AgentStatusCode.RequestNotToDoAnything));
 }
Exemplo n.º 14
0
        public ActionResult ShowConfirmed(int id)
        {
            OurTeam ourTeam = db.OurTeam.Find(id);

            ourTeam.Status = true;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 15
0
 public static OurTeam GetOurTeamItem(int id)
 {
     using (MainContext db = new MainContext())
     {
         OurTeam OurTeam = db.OurTeam.Where(d => d.OurTeamId == id).SingleOrDefault();
         return(OurTeam);
     }
 }
Exemplo n.º 16
0
 public OurTeamVM(OurTeam bo)
 {
     this.Id               = bo.Id;
     this.Name             = bo.Name;
     this.Description      = bo.Description;
     this.QQnumber         = bo.QQnumber;
     this.WeiboLink        = bo.WeiboLink;
     this.PersonalSiteLink = bo.PersonalSiteLink;
 }
Exemplo n.º 17
0
        public IActionResult CreateView()
        {
            OurTeam ourteam = new OurTeam();

            ViewData["Departments"] = new SelectList(_work.Departments.GetAll(), "Id", "Name");
            ViewData["Designation"] = new SelectList(_work.Designations.GetAll(), "Id", "Name");

            return(PartialView("_Create", ourteam));
        }
Exemplo n.º 18
0
        public async Task <IActionResult> EditPost(int id, CreateTeamVM category)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Xaiş olunur düzgün doldurun.");
                return(View(category));
            }
            OurTeam newCategory = await _context.OurTeam.FindAsync(id);

            if (newCategory == null)
            {
                return(View("Error"));
            }

            if (category.Photo != null)
            {
                string computerPhoto = Path.Combine(_env.WebRootPath, "images", newCategory.PhotoURL);

                if (System.IO.File.Exists(computerPhoto))
                {
                    System.IO.File.Delete(computerPhoto);
                }

                string fileName = await category.Photo.SaveAsync(_env.WebRootPath);

                newCategory.PhotoURL = fileName;
            }
            OurTeamLang azBlogLangFromDb = await _context.OurTeamLangs.FirstOrDefaultAsync(x => x.Lang.Code.ToLower() == "az" &&
                                                                                           x.OurTeamId == newCategory.Id);

            OurTeamLang ruBlogLangFromDb = await _context.OurTeamLangs.FirstOrDefaultAsync(x => x.Lang.Code.ToLower() == "ru" &&
                                                                                           x.OurTeamId == newCategory.Id);

            OurTeamLang enBlogLangFromDb = await _context.OurTeamLangs.FirstOrDefaultAsync(x => x.Lang.Code.ToLower() == "en" &&
                                                                                           x.OurTeamId == newCategory.Id);

            azBlogLangFromDb.FullName   = category.FullNameAZ;
            enBlogLangFromDb.FullName   = category.FullNameEN;
            ruBlogLangFromDb.FullName   = category.FullNameRU;
            azBlogLangFromDb.Profession = category.ProfessionAZ;
            enBlogLangFromDb.Profession = category.ProfessionEN;
            ruBlogLangFromDb.Profession = category.ProfessionRU;

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 19
0
        public ActionResult DeleteConfirmed(int id)
        {
            OurTeam ourTeam = db.OurTeams.Find(id);

            db.OurTeams.Remove(ourTeam);
            db.SaveChanges();
            Extension.Deletimg("~/Public2/images/team", ourTeam.Image);

            return(RedirectToAction("Index"));
        }
        public IActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            OurTeam worker = _db.OurTeams.Find(id);

            return(View(worker));
        }
Exemplo n.º 21
0
        public IActionResult DeleteTeam(int teamId)
        {
            OurTeam deletedTeam = teamRepository.DeleteTeam(teamId);

            if (deletedTeam != null)
            {
                TempData["message"] = $"{deletedTeam.Name} was deleted";
            }
            return(RedirectToAction("InformationList"));
        }
Exemplo n.º 22
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OurTeam outTeam = _repo.Get(id.Value);

            if (outTeam == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(outTeam));
        }
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            OurTeam team = _db.OurTeams.Find(id);

            if (team == null)
            {
                return(NotFound());
            }
            return(View(team));
        }
Exemplo n.º 24
0
        // GET: TallentAdmin/OurTeams/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OurTeam ourTeam = db.OurTeams.Find(id);

            if (ourTeam == null)
            {
                return(HttpNotFound());
            }
            return(View(ourTeam));
        }
Exemplo n.º 25
0
        public FileContentResult GetImageTeam(OurTeam item)
        {
            OurTeam team = teamRepository.Teams
                           .FirstOrDefault(g => g.Id == item.Id);

            if (team != null)
            {
                return(File(team.Image, team.ImageMimeType));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 26
0
        // GET: TallentAdmin/OurTeams/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OurTeam ourTeam = db.OurTeams.Find(id);

            if (ourTeam == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SocialID = new SelectList(db.Socials, "Id", "Link1", ourTeam.SocialID);
            return(View(ourTeam));
        }
Exemplo n.º 27
0
        public ActionResult Create([Bind(Include = "Id,Image,Name,position,Status")] OurTeam ourTeam, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    string fileName = null;
                    string today    = DateTime.Now.ToString("yyyy-MM-dd");
                    if (Image.ContentLength > 0 && Image.ContentLength <= 3 * 1024 * 1024)
                    {
                        if (Image.ContentType.ToLower() == "image/jpeg" ||
                            Image.ContentType.ToLower() == "image/jpg" ||
                            Image.ContentType.ToLower() == "image/png" ||
                            Image.ContentType.ToLower() == "image/gif"
                            )
                        {
                            DateTime dt        = DateTime.Now;
                            var      beforeStr = dt.Year + "_" + dt.Month + "_" + dt.Day + "_" + dt.Hour + "_" + dt.Minute + "_" + dt.Second;
                            fileName = beforeStr + Path.GetFileName(Image.FileName);
                            var newFilePath = Path.Combine(Server.MapPath("~/Public/images/"), fileName);

                            Image.SaveAs(newFilePath);
                            ourTeam.Image  = fileName;
                            ourTeam.Status = true;
                        }
                        else
                        {
                            ViewBag.EditError = "Photo type is not valid.";
                            return(View());
                        }
                    }
                    else
                    {
                        ViewBag.EditError = "Photo type should not be more than 3 MB.";
                        return(View());
                    }
                }
                else
                {
                    ourTeam.Image  = "default.jpg";
                    ourTeam.Status = true;
                }
                db.OurTeam.Add(ourTeam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(ourTeam));
        }
        public async Task <IActionResult> DeletePost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            OurTeam team = _db.OurTeams.Find(id);

            if (team == null)
            {
                return(NotFound());
            }
            Helper.DeleteImg(_env.WebRootPath, "img/OurTeam", team.Image);
            _db.OurTeams.Remove(team);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 29
0
        public ActionResult Create(OurTeam outTeam, HttpPostedFileBase OurTeamImage)
        {
            if (ModelState.IsValid)
            {
                #region Upload Image
                if (OurTeamImage != null)
                {
                    var newFileName = Guid.NewGuid() + Path.GetExtension(OurTeamImage.FileName);
                    OurTeamImage.SaveAs(Server.MapPath("/Files/OurTeamImages/" + newFileName));
                    outTeam.Image = newFileName;
                }
                #endregion

                _repo.Add(outTeam);
                return(RedirectToAction("Index"));
            }

            return(View(outTeam));
        }
Exemplo n.º 30
0
        public static dynamic EditOurTeam(OurTeam OurTeammodel)
        {
            using (MainContext db = new MainContext())
            {
                try
                {
                    OurTeam record = db.OurTeam.Where(d => d.OurTeamId == OurTeammodel.OurTeamId && d.Deleted == false).SingleOrDefault();
                    if (record != null)
                    {
                        record.Name     = OurTeammodel.Name;
                        record.Language = OurTeammodel.Language;
                        record.Content  = OurTeammodel.Content;
                        if (!string.IsNullOrEmpty(OurTeammodel.Image))
                        {
                            record.Image = OurTeammodel.Image;
                        }
                        record.PageSlug    = OurTeammodel.PageSlug;
                        record.TimeUpdated = DateTime.Now;
                        record.Linkedin    = OurTeammodel.Linkedin;

                        db.SaveChanges();

                        LogtrackManager logkeeper = new LogtrackManager();
                        logkeeper.LogDate    = DateTime.Now;
                        logkeeper.LogProcess = EnumLogType.Haber.ToString();
                        logkeeper.Message    = "Ekibimiz Kaydı Güncellendi";
                        logkeeper.User       = HttpContext.Current.User.Identity.Name;
                        logkeeper.Data       = record.Name;
                        logkeeper.AddInfoLog(logger);
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }