public ActionResult DeleteConfirmed(int id)
        {
            Tercuman tercuman = tercumanManager.Find(x => x.Id == id);

            tercumanManager.Delete(tercuman);

            return(RedirectToAction("Index"));
        }
        public ActionResult TercumeCreate(Translate translate, HttpPostedFileBase file)
        {
            //if (translate.Text.Length > 0 && translate.Text.Length <= 200)
            //{
            //    translate.Price = 20;
            //}
            //else if (translate.Text.Length > 200 && translate.Text.Length <= 400)
            //{
            //    translate.Price = 40;
            //}
            byte[] bytes;
            string contentType;

            using (BinaryReader br = new BinaryReader(file.InputStream))
            {
                bytes       = br.ReadBytes(file.ContentLength);
                contentType = file.ContentType;
            }
            translate.Price       = 30;
            translate.Data        = bytes;
            translate.ContentType = contentType;
            translate.Is_active   = false;
            translate.Is_finish   = false;
            translate.StartDate   = DateTime.Now;
            translate.EndDate     = DateTime.Now;
            Tercuman ter = tercumanManager.Find(x => x.Id == translate.ter_id);

            translate.Translator = ter;

            //int id = ter.Ter.Id;
            //Tercuman tercuman = tercumanManager.Find(x => x.Id == id);
            //ter.Tercuman.Password = tercuman.Password;
            //ter.Tercuman.Email = tercuman.Email;
            //ter.Owner = CurrentSession.User;

            Fatura fat    = new Fatura();
            var    errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)

            {
                translate.Owner = CurrentSession.User;
                translateManager.Insert(translate);
                fat.TercumeUser    = CurrentSession.User;
                fat.Translator     = translate.Translator;
                fat.Translate      = translate;
                fat.UserName       = CurrentSession.User.Name;
                fat.TranslatorName = translate.Translator.Name;
                fat.ToplamUcret    = translate.Price;
                double u = translate.Price;
                fat.TercumanUcret = u * 0.3;
                faturaManager.Insert(fat);
                return(RedirectToAction("Index"));
            }

            //ViewBag.CategoryId = new SelectList(CacheHelper.GetCategoriesFromCache(), "Id", "Title", note.CategoryId);
            return(View(translate));
        }
        public ActionResult Edit(Tercuman tercuman)
        {
            if (ModelState.IsValid)
            {
                BusinessLayerResult <Tercuman> res = tercumanManager.Update(tercuman);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(tercuman));
                }

                return(RedirectToAction("Index"));
            }
            return(View(tercuman));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Tercuman tercuman = tercumanManager.Find(x => x.Id == id.Value);

            if (tercuman == null)
            {
                return(HttpNotFound());
            }

            return(View(tercuman));
        }
        public ActionResult Create(Tercuman tercuman)
        {
            if (ModelState.IsValid)
            {
                tercuman.Create_on = DateTime.Now;
                BusinessLayerResult <Tercuman> res = tercumanManager.Insert(tercuman);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(tercuman));
                }

                return(RedirectToAction("Index"));
            }

            return(View(tercuman));
        }
        public ActionResult EditProfileTercuman(Tercuman model, HttpPostedFileBase ProfileImage)
        {
            if (ModelState.IsValid)
            {
                if (ProfileImage != null &&
                    (ProfileImage.ContentType == "image/jpeg" ||
                     ProfileImage.ContentType == "image/jpg" ||
                     ProfileImage.ContentType == "image/png"))
                {
                    string filename = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}";

                    ProfileImage.SaveAs(Server.MapPath($"~/images/{filename}"));
                    model.ProfileImageFilename = filename;
                }

                BusinessLayerResult <Tercuman> res = tercumanManager.UpdateProfile(model);

                if (res.Errors.Count > 0)
                {
                    ErrorViewModelTercuman errorNotifyObj = new ErrorViewModelTercuman()
                    {
                        Items          = res.Errors,
                        Title          = "Profil Güncellenemedi.",
                        RedirectingUrl = "/Home/EditProfileTercuman"
                    };

                    return(View("ErrorTercuman", errorNotifyObj));
                }

                //Profil güncellendiği için session güncellendi.
                CurrentSessionsTercuman.Set <Tercuman>("login", res.Result);

                return(RedirectToAction("ShowTercumanProfile"));
            }

            return(View(model));
        }