Esempio n. 1
0
 public IActionResult AddCollaborator([FromBody] Collaborator collaboratorModel)
 {
     try
     {
         var AccountId = Convert.ToInt32(HttpContext.Items["userId"]);
         collaboratorModel.SenderEmail = Convert.ToString(HttpContext.Items["email"]);
         Collaborator collaborator = _collaboratorService.AddCollaborator(AccountId, collaboratorModel.SenderEmail, collaboratorModel);
         if (collaborator == null)
         {
             return(NotFound(new ServiceResponse <Collaborator> {
                 StatusCode = (int)HttpStatusCode.NotFound, Message = "Internal Server Error", Data = null
             }));
         }
         _msmq.AddToQueue(collaboratorModel.RecieverEmail + " " + "Collaborated Successfully by" + collaboratorModel.SenderEmail + "  " + System.DateTime.Now.ToString());
         return(Ok(new ServiceResponse <Collaborator> {
             StatusCode = (int)HttpStatusCode.OK, Message = "Added Successfully", Data = collaborator
         }));
     }
     catch (Exception)
     {
         return(BadRequest(new ServiceResponse <Collaborator> {
             StatusCode = (int)HttpStatusCode.BadRequest, Message = "Page Not Found", Data = null
         }));
     }
 }
Esempio n. 2
0
        public ActionResult GetNotes()
        {
            var AccountId = Convert.ToInt32(HttpContext.Items["userId"]);
            List <NotesViewModel> notes = new List <NotesViewModel>();

            try {
                var Chache = this._distrubutedCache.GetString(key);
                if (Chache == null)
                {
                    notes = _service.GetNotes(AccountId);
                    if (notes == null)
                    {
                        return(NotFound(new ServiceResponse <List <Note> > {
                            StatusCode = (int)HttpStatusCode.NotFound, Message = "Internal Server Error", Data = null
                        }));
                    }
                    else
                    {
                        var jsonModel = JsonConvert.SerializeObject(notes);
                        this._distrubutedCache.SetString(key, jsonModel);
                        return(Ok(new ServiceResponse <List <NotesViewModel> > {
                            StatusCode = (int)HttpStatusCode.Created, Message = "successful", Data = notes
                        }));
                    }
                }
                var model = JsonConvert.DeserializeObject <List <NotesViewModel> >(Chache);
                _msmq.AddToQueue("User with AccountId " + AccountId + " " + "have seen Notes " + "  " + System.DateTime.Now.ToString());
                return(Ok(new ServiceResponse <List <NotesViewModel> > {
                    StatusCode = (int)HttpStatusCode.OK, Message = "successful", Data = model
                }));
            }
            catch (Exception)
            {
                return(BadRequest(new ServiceResponse <List <NotesViewModel> > {
                    StatusCode = (int)HttpStatusCode.BadRequest, Message = "Page Not Found", Data = null
                }));
            }
        }
 public ActionResult AddLable(int NoteId, [FromBody] Lable lable)
 {
     try
     {
         var   AccountId = Convert.ToInt32(HttpContext.Items["userId"]);
         Lable result    = _lableService.AddLable(AccountId, NoteId, lable);
         if (result == null)
         {
             return(NotFound(new ServiceResponse <Lable> {
                 StatusCode = (int)HttpStatusCode.NotFound, Message = "Internal Server Error", Data = null
             }));
         }
         _msmq.AddToQueue(AccountId + " " + "label Added Successfully " + "  " + System.DateTime.Now.ToString());
         return(Ok(new ServiceResponse <Lable> {
             StatusCode = (int)HttpStatusCode.OK, Message = "successful", Data = result
         }));
     }
     catch (Exception)
     {
         return(BadRequest(new ServiceResponse <Lable> {
             StatusCode = (int)HttpStatusCode.BadRequest, Message = "Page Not Found", Data = null
         }));
     }
 }
        public ActionResult RegisterUser([FromBody] Account account)
        {
            Account user = _registrationService.RegisterUser(account);

            try
            {
                if (user == null)
                {
                    return(NotFound(new ServiceResponse <Account> {
                        StatusCode = (int)HttpStatusCode.NotFound, Message = "Internal Server Error", Data = null
                    }));
                }
                _mamq.AddToQueue(account.EmailId + " " + "Registered Successfully " + "  " + System.DateTime.Now.ToString());
                return(Ok(new ServiceResponse <Account> {
                    StatusCode = (int)HttpStatusCode.OK, Message = "successful", Data = user
                }));
            }
            catch (Exception)
            {
                return(BadRequest(new ServiceResponse <Account> {
                    StatusCode = (int)HttpStatusCode.BadRequest, Message = "Page Not Found", Data = null
                }));
            }
        }