Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // POST: Client/Create
- // To protect from overposting attacks, please enable the specific properties you want to bind to, for
- // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Create([Bind(Include = "ClientID,AccountNumber,FirstName,MiddleName,LastName,NickName,DOB,GenderTypeID,FacilityID,StatusID,StartDate,StartTimeID,EndDate,EndTime,ResponsiblePartyID,DateAdded,AddedBy,DateChanged,ChangedBy,DestroyDate")] client__information client__information, HttpPostedFileBase upload)
- {
- if (ModelState.IsValid)
- {
- if (upload != null && upload.ContentLength > 0)
- {
- var avatar = new File
- {
- FileName = System.IO.Path.GetFileName(upload.FileName),
- FileType = FileType.Avatar,
- ContentType = upload.ContentType
- };
- using (var reader = new System.IO.BinaryReader(upload.InputStream))
- {
- avatar.Content = reader.ReadBytes(upload.ContentLength);
- }
- client__information.Files = new List<File> { avatar };
- }
- //Used on create-post to automatically add Date and Time into DateAdded column.
- client__information.DateAdded = DateTime.Now;
- db.client__information.Add(client__information);
- db.SaveChanges();
- return RedirectToAction("Index");
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Edit([Bind(Include = "ClientID,AccountNumber,FirstName,MiddleName,LastName,NickName,DOB,GenderTypeID,FacilityID,StatusID,StartDate,StartTimeID,EndDate,EndTime,ResponsiblePartyID,AddedBy,DateChanged,ChangedBy,DestroyDate")] client__information client__information, HttpPostedFileBase upload)
- {
- if (ModelState.IsValid)
- {
- if (upload != null && upload.ContentLength > 0)
- {
- var avatar = new File
- {
- FileName = System.IO.Path.GetFileName(upload.FileName),
- FileType = FileType.Avatar,
- ContentType = upload.ContentType
- };
- using (var reader = new System.IO.BinaryReader(upload.InputStream))
- {
- avatar.Content = reader.ReadBytes(upload.ContentLength);
- }
- client__information.Files = new List<File> { avatar };
- }
- //Add to column DateChanged on Edit
- client__information.DateChanged = DateTime.Now;
- db.Entry(client__information).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("Index");
Add Comment
Please, Sign In to add comment