public async Task <IActionResult> CreateRecord(RecordDTO recordDTO)
        {
            recordService.CreateRecord(recordDTO);

            return(Redirect("~/Home/Index"));
            //return View("Index",CRVM); --RETURNS POST!
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] CreateRecordRequest request)
        {
            var record = new Record
            {
                Id          = Guid.NewGuid(),
                Teacher     = request.Teacher,
                Room        = request.Room,
                Note        = request.Note,
                ClassNumber = request.ClassNumber,
                ClassLetter = request.ClassLetter,
                Lessons     = request.Lessons,
                Date        = request.Date
            };

            var created = await _recordService.CreateRecord(record);

            if (created == false)
            {
                return(BadRequest());
            }

            var baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
            var locationUri = baseUrl + "/" + ApiRoutes.AdminRecords.Get.Replace("{recordId}", record.Id.ToString());

            var response = new RecordResponse {
                Id = record.Id
            };

            return(Created(locationUri, response));
        }
Ejemplo n.º 3
0
        public ActionResult Create(ProjectRecordViewModel record)
        {
            int userId = users.GetUserIdByName(User.Identity.Name);

            if (ModelState.IsValid)
            {
                service.CreateRecord(
                    new RecordDTO()
                {
                    UserId         = userId,
                    TaskId         = record.TaskId,
                    Hours          = record.Hours,
                    Note           = record.Note,
                    RecordDateTime = DateTime.Parse(record.Date + ',' + record.Time, new CultureInfo("ru", false)),
                    ProjectId      = record.ProjectId
                }
                    );

                return(RedirectToAction(nameof(UserList)));
            }
            var userProjects = projects.GetUserProjects(userId, (int)ProjectRole.Employee);

            record.Projects = userProjects;
            return(View(record));
        }
        public void Can_Get_Assigned_AggregateId()
        {
            service
            .CreateRecord(new CreateDummyExample())
            .AssignAggregateId();

            service.GetAggregateId().Should().NotBe(aggregateId);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> CreateNewRecord(RecordModel record)
        {
            try
            {
                User user = await _userManager.GetUserAsync(User);

                _recordService.CreateRecord(record, user.Id);
                List <RecordModel> records = _recordService.SearchRecords(record.ThemeId);
                return(PartialView("_AllRecords", records));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e));
            }
        }
Ejemplo n.º 6
0
        public override void OnActionExecuted(HttpActionExecutedContext filterContext)
        {
            bool success;

            if (filterContext.ActionContext.ModelState.IsValid)
            {
                success = true;
                transactionService.Commit();
            }
            else
            {
                success = false;
                transactionService.RollBack();
            }

            recordService.CreateRecord(queryPath, userId, success);

            base.OnActionExecuted(filterContext);
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> CreateRecord([FromBody] CreateRecordRequest createRecord)
        {
            try
            {
                var userIdClaim = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "userId");
                if (userIdClaim == null)
                {
                    return(BadRequest(new { message = "Invalid token" }));
                }

                var record = await recordService.CreateRecord(createRecord, userIdClaim.Value);

                return(Ok(new { record }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Ejemplo n.º 8
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            bool success;

            if (filterContext.Controller.ViewData.ModelState.IsValid && filterContext.HttpContext.Error == null)
            {
                success = true;
                transactionService.Commit();
            }
            else
            {
                success = false;
                transactionService.RollBack();
            }

            recordService.CreateRecord(queryPath, userId, success);

            base.OnActionExecuted(filterContext);
        }