예제 #1
0
        public IActionResult PostReference(Reference reference, string id)
        {
            string userId;

            try
            {
                userId = User.Claims.First(c => c.Type == "UserID").Value;
            }
            catch
            {
                return(Unauthorized());
            }
            reference.Sender   = _userService.GetSingleByCondition(s => s.Id == userId, null);
            reference.Receiver = _userService.GetSingleByCondition(s => s.Id == id, null);
            if (reference.Receiver == null)
            {
                return(NotFound());
            }
            reference.CreateDate = DateTime.Now;
            _referenceService.Add(reference);
            var notification = new Notification()
            {
                Type     = NotificationType.Reference,
                Sender   = reference.Sender,
                Receiver = reference.Receiver,
            };

            _notificationService.Add(notification);
            _referenceService.SaveChanges();
            return(Ok(reference));
        }
예제 #2
0
 public ActionResult Index(Reference reference, HttpPostedFileBase Image)
 {
     if (ModelState.IsValid)
     {
         if (Image != null)
         {
             WebImage img      = new WebImage(Image.InputStream);
             FileInfo fotoInfo = new FileInfo(Image.FileName);
             string   newFoto  = Guid.NewGuid().ToString() + fotoInfo.Extension;
             img.Resize(800, 400);
             img.Save("~/Areas/Admin/Uploads/ReferenceFoto/" + newFoto);
             reference.Image = "/Areas/Admin/Uploads/ReferenceFoto/" + newFoto;
         }
     }
     _referenceService.Add(reference);
     return(RedirectToAction("Index"));
 }
 public ActionResult Post([FromBody] CovidTestModel model)
 {
     try
     {
         _referenceService.Add(model);
         var successModel = new Status()
         {
             StatusCode = 200,
             Message    = "Added Successfully"
         };
         return(Ok(successModel));
     }
     catch (Exception ex)
     {
         var errorModel = new Status()
         {
             Message = ex.Message
         };
         Log.Error(ex, ex.Message);
         return(StatusCode(500, errorModel));
     }
 }
예제 #4
0
 public JsonResult storeAdd(Reference reference)
 {
     _referenceService.Add(reference);
     return(Json("Referans başarıyla eklendi"));
 }