Exemplo n.º 1
0
        public async Task <IHttpActionResult> Post(ReminderNoteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                //ApplicationUser test = GetCurrentUser();
                //model.UserAccount = test;
                var stf = await _reminderNoteService.InsertAsync(model, GetCurrentUserID());

                _unitOfWorkAsync.Commit();
                var resultObject = new ReminderNoteViewModel()
                {
                    Note         = stf.Note,
                    ReminderDate = stf.ReminderDate,
                    ID           = stf.Id,
                    Serial       = stf.Serial
                };
                return(Created(resultObject));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public bool Update(ReminderNoteViewModel model)
        {
            var data = Find(model.ID);

            if (data != null)
            {
                data.ReminderDate     = model.ReminderDate;
                data.Note             = model.Note;
                data.LastModifiedDate = DateTime.Now;
            }
            return(true);
        }
Exemplo n.º 3
0
        public async Task <ReminderNoteViewModel> UpdateAsync(ReminderNoteViewModel model)
        {
            try
            {
                await Task.Run(() => Update(model));

                return(model);
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
Exemplo n.º 4
0
        public ReminderNote Insert(ReminderNoteViewModel model, string CurrentId)
        {
            var data = new ReminderNote();

            data.Note             = model.Note;
            data.UserAccount      = model.UserAccount;
            data.Event            = _eventService.Find(model.EventID);
            data.ReminderDate     = model.ReminderDate;
            data.Serial           = model.Serial;
            data.CreatDate        = DateTime.Now;
            data.Delete           = false;
            data.UserAccount      = _userRepository.Find(CurrentId);
            data.LastModifiedDate = DateTime.Now;
            base.Insert(data);
            return(data);
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> Put(Guid key, ReminderNoteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                await _reminderNoteService.UpdateAsync(model);

                _unitOfWorkAsync.Commit();
                return(Updated(model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public IActionResult Post([FromBody] ReminderNoteViewModel reminderNoteViewModel)
        {
            if (ModelState.IsValid)
            {
                var currentUser = User.Claims.Single(c => c.Type == ClaimTypes.Email).Value;

                _context.ReminderNote.Add(new ReminderNote
                {
                    Notes = reminderNoteViewModel.Notes,
                    User  = currentUser
                });

                _context.SaveChanges();

                return(Ok());
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
        public IActionResult Put(int id, [FromBody] ReminderNoteViewModel reminderNoteViewModel)
        {
            if (ModelState.IsValid)
            {
                var reminderNote = _context.ReminderNote.SingleOrDefault(b => b.Id == id);

                if (reminderNote == null)
                {
                    return(NotFound());
                }
                else
                {
                    reminderNote.Notes = reminderNoteViewModel.Notes;

                    _context.SaveChanges();

                    return(Ok());
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 8
0
 public async Task <ReminderNote> InsertAsync(ReminderNoteViewModel model, string CurrentId)
 {
     return(await Task.Run(() => Insert(model, CurrentId)));
 }