public ActionResult Editme(Guid id, string eposta, HttpPostedFileBase foto) { Guid ad = id; if (eposta == "" && foto == null) { TempData["lan"] = "Fill the Gaps"; return(RedirectToAction("Index/" + ad)); } if (eposta != "") { MembershipUser ads = Membership.GetUser(id); Kullanici kal = ctx.Kullanicis.FirstOrDefault(x => x.KullaniciId == id); ads.Email = eposta; kal.Email = ads.Email; } if (foto != null) { Kullanici kal = ctx.Kullanicis.FirstOrDefault(x => x.KullaniciId == id); Image profoto = Image.FromStream(foto.InputStream); int width = Convert.ToInt32(ConfigurationManager.AppSettings["profilW"]); int height = Convert.ToInt32(ConfigurationManager.AppSettings["profilH"]); string name = "/Content/Uploads/ProfilFoto/" + Guid.NewGuid() + Path.GetExtension(foto.FileName); Bitmap bm = new Bitmap(profoto, width, height); bm.Save(Server.MapPath(name)); kal.ProfilFoto = name; } ctx.SaveChanges(); return(RedirectToAction("Index/" + ad)); }
public ActionResult Yukle(int KategoriId, HttpPostedFileBase img) { Kategori ktg = ctx.Kategoris.FirstOrDefault(x => x.KategoriId == KategoriId); string name = "/Content/Uploads/Olaylar/" + Guid.NewGuid() + Path.GetExtension(img.FileName); ktg.ResimYolu = name; img.SaveAs(Server.MapPath(name)); ctx.SaveChanges(); return(View()); }
public ActionResult KampanyaBaslat(Kampanya ka, HttpPostedFileBase kampresim, string[] StuffName, int[] Miktari, string[] Birim, HttpPostedFileBase[] ResimID) { if (kampresim != null) { Image img = Image.FromStream(kampresim.InputStream); int width = Convert.ToInt32(ConfigurationManager.AppSettings["kampKucukW"]); int height = Convert.ToInt32(ConfigurationManager.AppSettings["kampKucukh"]); string name = "/Content/Uploads/KucukFoto" + Guid.NewGuid() + Path.GetExtension(kampresim.FileName); Bitmap bm = new Bitmap(img, width, height); bm.Save(Server.MapPath(name)); ka.KampanyaFoto = name; int wd = Convert.ToInt32(ConfigurationManager.AppSettings["kampBuyukW"]); int hd = Convert.ToInt32(ConfigurationManager.AppSettings["kampBuyukH"]); string name2 = "/Content/Uploads/BuyukFoto" + Guid.NewGuid() + Path.GetExtension(kampresim.FileName); Bitmap bm2 = new Bitmap(img, wd, hd); bm.Save(Server.MapPath(name2)); ka.KampanyaFotoB = name2; } //eşya nesnesini yukarıda oluşturmamım bir sebebi var ama ne mk Stuff esya = new Stuff(); Guid baslatanId = new Guid(); baslatanId = ctx.Kullanicis.FirstOrDefault(x => x.UserAdi == User.Identity.Name).KullaniciId; ka.Baslatan = baslatanId; ka.BasariliMi = false; ka.OnaylandiMi = false; ka.BaslamaTarihi = DateTime.Now; // ka.StuffID = 1; //ka.DonateID = 0; ctx.Kampanyas.Add(ka); ctx.SaveChanges(); int d = ka.KampanyaId; Resim rsm = new Resim(); if (ResimID[0] != null) { for (int i = 0; i < ResimID.Count(); i++) { string name = "/Content/Uploads/Olaylar/" + Guid.NewGuid() + Path.GetExtension(ResimID[i].FileName); // Image img = Image.FromStream(ResimID[i].InputStream); // Bitmap bm = new Bitmap(img); ResimID[i].SaveAs(Server.MapPath(name)); rsm.ResimBuyukYol = name; rsm.ResimKucukYol = name; rsm.KampanyaID = d; ctx.Resims.Add(rsm); ctx.SaveChanges(); } } if (rsm.ResimId != 0) { ka.ResimID = rsm.ResimId; } for (int i = 0; i < StuffName.Count() && i < Birim.Count() && i < Miktari.Count(); i++) { esya.Birim = Birim[i]; esya.Miktari = Miktari[i]; esya.StuffName = StuffName[i]; esya.KampanyaID = 0; esya.KalanMiktar = 0; if (esya.KampanyaID != -1) { esya.KampanyaID = d; } ctx.Stuffs.Add(esya); try { ctx.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } } // ctx.Kampanyas.Add(ka); //AHANDA BURADA HATA VERİYOR // ka.StuffID = esya.StuffId; // ctx.Kampanyas.Add(ka); ctx.SaveChanges(); return(RedirectToAction("KampanyaDetay/" + ka.KampanyaId)); }
public ActionResult Kayit(Kullanici kl) { MembershipCreateStatus durum; MembershipUser ASS = Membership.CreateUser(kl.UserAdi, kl.Parola, kl.Email, kl.GizliSoru, kl.GizliCevap, true, out durum); string mesaj = " "; switch (durum) { case MembershipCreateStatus.Success: break; case MembershipCreateStatus.InvalidUserName: mesaj += "Invalid User Name"; break; case MembershipCreateStatus.InvalidPassword: mesaj += "Invalid Password"; break; case MembershipCreateStatus.InvalidQuestion: mesaj += "Invalid Secret Question"; break; case MembershipCreateStatus.InvalidAnswer: mesaj += "Invalid Secret Answer"; break; case MembershipCreateStatus.InvalidEmail: mesaj += "Invalid E-mail"; break; case MembershipCreateStatus.DuplicateUserName: mesaj += "Already This User Name Exist"; break; case MembershipCreateStatus.DuplicateEmail: mesaj += "Already This E-mail Exist"; break; case MembershipCreateStatus.UserRejected: mesaj += "Rejected"; break; case MembershipCreateStatus.InvalidProviderUserKey: break; case MembershipCreateStatus.DuplicateProviderUserKey: break; case MembershipCreateStatus.ProviderError: break; default: break; } ViewBag.mesaj = mesaj; if (durum == MembershipCreateStatus.Success) { Guid id = (Guid)Membership.GetUser(kl.UserAdi).ProviderUserKey; Roles.AddUserToRole(kl.UserAdi, "UYE"); kl.ProfilFoto = null; kl.IsAdmin = false; kl.IsDonator = false; kl.IsLeader = false; kl.KullaniciId = id; ctx.Kullanicis.Add(kl); ctx.SaveChanges(); return(RedirectToAction("Giris", "Yonetim")); } return(View()); }