public ActionResult Create(RecordFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("RecordForm", model));
            }

            var record = new Record
            {
                UserID      = User.Identity.GetUserId(),
                IsRevenue   = model.IsRevenue,
                Date        = model.Date,
                Charge      = model.Charge,
                Category    = model.Category,
                Subcategory = model.Subcategory,
                Name        = model.Name
            };

            _recordsRepository.AddRecord(record);
            _recordsRepository.Complete();

            TempData["message"] = string.Format("Zapisano {0} ", record.Name);
            return(RedirectToAction("RecordsList", "Records"));
        }
Esempio n. 2
0
        public IHttpActionResult DeleteRecord(int id)
        {
            var userId = User.Identity.GetUserId();

            var record = _recordRepository.GetRecord(userId, id);

            if (record == null)
            {
                return(NotFound());
            }

            _recordRepository.DeleteRecord(record);
            _recordRepository.Complete();

            return(Ok());
        }