Esempio n. 1
0
 public async Task <IActionResult> Upsert(Institute obj)
 {
     if (ModelState.IsValid)
     {
         var files = HttpContext.Request.Form.Files;
         if (files.Count > 0)
         {
             byte[] p1 = null;
             using (var fs1 = files[0].OpenReadStream())
             {
                 using (var ms1 = new MemoryStream())
                 {
                     fs1.CopyTo(ms1);
                     p1 = ms1.ToArray();
                 }
             }
             obj.Picture = p1;
         }
         if (obj.Id == 0)
         {
             await _insRepo.CreateAsync(SD.InstituteAPIPath, obj, HttpContext.Session.GetString("JWToken"));
         }
         else
         {
             await _insRepo.UpdateAsync(SD.InstituteAPIPath + obj.Id, obj, HttpContext.Session.GetString("JWToken"));
         }
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(View(obj));
     }
 }