public async Task <ActionResult> Edit(NoticeForm form) { if (ModelState.IsValid) { var notice = new Notice { Id = form.Id, AdditionalLocation = form.AdditionalLocation, Building = Int32.Parse(form.Building), Category = Int32.Parse(form.Category), Comment = form.Comment, PhoneNumber = form.PhoneNumber, ReporterName = form.ReporterName }; await _proxy.PutNotice(form.Id, notice); return(RedirectToAction("Index", "Notice")); } form.Buildings = _buildings; form.Categories = _categories; return(View(form)); }
private void tsbtnNotice_Click(object sender, EventArgs e) { NoticeForm form = new NoticeForm(); form.ShowDialog(); noticeCount = GlobalService.NoticeList.Count; tsbtnNotice.Text = "Notice" + " (" + noticeCount + ")"; }
public ActionResult Create() { var form = new NoticeForm { Buildings = _buildings, Categories = _categories }; return(View(form)); }
public async Task <ActionResult> Create(NoticeForm form, HttpPostedFileBase photo) { if (ModelState.IsValid) { var notice = new Notice { AdditionalLocation = form.AdditionalLocation, Building = Int32.Parse(form.Building), Category = Int32.Parse(form.Category), Comment = form.Comment, PhoneNumber = form.PhoneNumber, ReporterName = form.ReporterName }; await _proxy.PostNotice(notice); if (IsImage(photo.ContentType)) { // if photo is not lager than 2 MB if (photo.ContentLength < 2000000) { var stream = new MemoryStream(); photo.InputStream.CopyTo(stream); var photoBytes = stream.ToArray(); var base64Photo = Convert.ToBase64String(photoBytes); var jsonPhoto = new Photo { ContentType = photo.ContentType, ContentLength = photo.ContentLength, EncodedFile = base64Photo, FileName = photo.FileName, Name = form.PhotoName }; await _photoProxy.Post(jsonPhoto); } } return(RedirectToAction("Index", "Notice")); } form.Buildings = _buildings; form.Categories = _categories; return(View(form)); }
public async Task <ActionResult> Edit(int id) { var notice = await _proxy.GetNotice(id); var form = new NoticeForm { Id = notice.Id, AdditionalLocation = notice.AdditionalLocation, Building = notice.Building.ToString(), Buildings = _buildings, Categories = _categories, Category = notice.Category.ToString(), Comment = notice.Comment, PhoneNumber = notice.PhoneNumber, ReporterName = notice.ReporterName }; return(View(form)); }