public async Task <JsonResult> Modify(CPType model) { model.Name = PinyingHelper.MkPinyinString(model.Title);//转换编码 if (model.Type == 1) { model.CodeList = "0,1,2,3,4,5,6,7,8,9"; } else if (model.Type == 2) { model.CodeList = "01,02,03,04,05,06,07,08,09,10,11"; } model.ShortName = model.Title; var msg = 0; try { db.CPType.Update(model); msg = await db.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(Json(msg)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Description,Extension,FilePath,FileSize,Year,Month,ContentType,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] Media media) { if (ModelState.IsValid) { media.CreateDate = DateTime.Now; media.CreatedBy = User.Identity.Name; media.UpdateDate = DateTime.Now; media.UpdatedBy = User.Identity.Name; //Upload işlemi if (!String.IsNullOrEmpty(media.FilePath)) { FileInfo fileInfo = new FileInfo(Server.MapPath("~" + media.FilePath)); media.FileSize = (float)TempData["deneme"]; media.Extension = fileInfo.Extension; media.ContentType = fileInfo.Extension; } db.Medias.Add(media); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(media)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] ApplicationUser applicationUser) { if (ModelState.IsValid) { db.Entry(applicationUser).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(applicationUser)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Side side) { if (ModelState.IsValid) { db.Sides.Add(side); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(side)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Description,Extension,FilePath,FileSize,Year,Month,ContentType,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Media media) { if (ModelState.IsValid) { db.Medias.Add(media); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(media)); }
public async Task <ActionResult> Create([Bind(Include = "Id,FirstName,LastName,Email,Phone,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] Contact contact) { if (ModelState.IsValid) { contact.CreateDate = DateTime.Now; contact.CreatedBy = User.Identity.Name; contact.UpdateDate = DateTime.Now; contact.UpdatedBy = User.Identity.Name; db.Contacts.Add(contact); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(contact)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] Department department) { if (ModelState.IsValid) { department.CreateDate = DateTime.Now; department.CreatedBy = User.Identity.Name; department.UpdateDate = DateTime.Now; department.UpdatedBy = User.Identity.Name; db.Departments.Add(department); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(department)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Category category) { if (ModelState.IsValid) { category.CreatedDate = DateTime.Now; category.CreatedBy = User.Identity.Name; category.UpdatedDate = DateTime.Now; category.UpdatedBy = User.Identity.Name; db.Categories.Add(category); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(category)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] Side side) { if (ModelState.IsValid) { side.CreateDate = DateTime.Now; side.CreatedBy = User.Identity.Name; side.UpdateDate = DateTime.Now; side.UpdatedBy = User.Identity.Name; db.Sides.Add(side); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(side)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Email,Phone,Fax,WebSite,Address,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] Customer customer) { if (ModelState.IsValid) { customer.CreateDate = DateTime.Now; customer.CreatedBy = User.Identity.Name; customer.UpdateDate = DateTime.Now; customer.UpdatedBy = User.Identity.Name; db.Customers.Add(customer); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Email,Phone,Fax,WebSite,Address,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Customer customer) { customer.CreatedDate = DateTime.Now; customer.CreatedBy = User.Identity.Name; customer.UpdatedDate = DateTime.Now; customer.UpdatedBy = User.Identity.Name; if (ModelState.IsValid) { db.Customers.Add(customer); //burda son customer eklemenin id sini çekme metodunu bul. iki kategori için kullanıcaz. await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Title,Description,Status,CategoryId,Attachment,DepartmentId,SideId,CustomerId,ManagerId,OrganizatorId,MeetingDate,MeetingHour,PlannedDate,PlannedHour,FinishDate,FinishHour,ReviseDate,ReviseHour,ConversationSubject,SupporterCompany,SupporterDoctor,ConversationAttendeeCount,ScheduledOrganizationDate,ScheduledOrganizationHour,MailingSubjects,PosterSubject,PosterCount,Elearning,TypesOfScans,AsoCountInScans,TypesOfOrganization,AsoCountInOrganization,TypesOfVaccinationOrganization,AsoCountInVaccinationOrganization,AmountOfCompensantionForPoster,CorporateProductivityReport,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] ToDoItem toDoItem) { if (ModelState.IsValid) { toDoItem.CreateDate = DateTime.Now; toDoItem.CreatedBy = User.Identity.Name; toDoItem.UpdateDate = DateTime.Now; toDoItem.UpdatedBy = User.Identity.Name; db.ToDoItems.Add(toDoItem); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", toDoItem.CategoryId); ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", toDoItem.CustomerId); ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "Name", toDoItem.DepartmentId); ViewBag.ManagerId = new SelectList(db.Contacts, "Id", "FirstName", toDoItem.ManagerId); ViewBag.OrganizatorId = new SelectList(db.Contacts, "Id", "FirstName", toDoItem.OrganizatorId); ViewBag.SideId = new SelectList(db.Sides, "Id", "Name", toDoItem.SideId); return(View(toDoItem)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Description,Extension,FilePath,FileSize,Year,Month,ContentType,CreatedBy,CreateDate,UpdatedBy,UpdateDate")] Media media) { if (ModelState.IsValid && Kayit == true) { media.CreateDate = DateTime.Now; media.CreatedBy = User.Identity.Name; media.UpdateDate = DateTime.Now; media.UpdatedBy = User.Identity.Name; // Upload İşlemi: if (!String.IsNullOrEmpty(media.FilePath)) { FileInfo fileInfo = new FileInfo(Server.MapPath("~" + media.FilePath)); //media.FileSize = (float)fileInfo.Length / (float)1024; media.FileSize = (float)TempData["fileSize"]; media.Extension = fileInfo.Extension; media.ContentType = fileInfo.Extension; //var requestFiles = Request.Files[0]; //HttpPostedFileBase file = Request.Files[requestFiles.ToString()]; //if (!System.IO.File.Exists(fileInfo.FullName)) //{ // file.SaveAs(fileInfo.FullName); //} //else //{ // throw new Exception("Bu dosya mevcut."); //} } db.Medias.Add(media); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } media.FilePath = "/uploads" + (string)TempData["categoryFolder"] + (string)TempData["fileName"]; return(View(media)); }
public async Task <bool> SaveChangesAsync() { await _db.SaveChangesAsync(); return(true); }