Esempio n. 1
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                ToDo todo = new ToDo(Guid.NewGuid())
                {
                    Task        = collection["Task"],
                    DueDateTime = DateTime.Parse(collection["DueDateTime"]),
                    CreatedBy   = User.Identity.Name,
                    CreatedWhen = DateTime.Now,
                    Done        = false,
                    AssignedTo  = User.Identity.Name
                };

                await _todoRepository.Create(todo);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Logger.Error(e, "Exception occured.");

                return(View());
            }
        }
Esempio n. 2
0
        public async Task <ResultData> Post(CreateToDoRequest request)
        {
            var toDo = new ToDo(request);

            await _repository.Create(toDo);

            _unitOfWork.Commit();

            return(SuccessData(EGenericOperations.Record_Saved_Successfully.GetDescription()));
        }
Esempio n. 3
0
        public async Task <ToDoVM> Add(CreateToDoVM item)
        {
            var toDo = mapper.Map <ToDo>(item);

            toDo.UserId = loginService.GetUser().Id;
            toDo.State  = TaskState.New;
            await todoRepository.Create(toDo);

            await todoRepository.Save();

            return(await Task.FromResult(mapper.Map <ToDoVM>(toDo)));
        }
Esempio n. 4
0
        private void Add(object parameter)
        {
            try
            {
                var myToDo = _ToDoRepository.Create();

                this.DataList     = _ToDoRepository.GetAll().ToList();
                this.SelectedToDo = myToDo;
            }
            catch (Exception ex)
            {
                Logging.WriteLog("Fehler: " + ex.ToString());
                MessageBox.Show("Fehler: " + ex.Message);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// This is to add a new todo item
 /// Here we have used automapper to convert the domain model to DAL model
 /// </summary>
 /// <param name="item"></param>
 /// <returns>After adding todo item it will append the id in todo object and return that object</returns>
 public Domain.Models.ToDoItem Add(Domain.Models.ToDoItem item)
 {
     if (null != item)
     {
         //This is to initilize the automapper
         Mapper.Initialize(cfg => cfg.CreateMap <Domain.Models.ToDoItem, DataAccessLayer.Models.ToDoItem>());
         //This is convert the Domain model to DAL model object, this will take domain model as parameter and return DAL model as response
         DataAccessLayer.Models.ToDoItem itemDAL = Mapper.Map <Domain.Models.ToDoItem, DataAccessLayer.Models.ToDoItem>(item);
         var record = _repository.Create(itemDAL);
         if (null != record)
         {
             item.Id = record.Id;
         }
     }
     return(item);
 }
 public IActionResult Post([FromBody] ToDoDTO tododto)
 {
     {
         var todo = _mapper.Map <ToDo>(tododto);
         if (todo == null)
         {
             return(BadRequest());
         }
         string name   = HttpContext.User.Identity.Name;
         int    userId = _repository.GetUserId(name);
         todo.Check  = false;
         todo.UserId = userId;
         _repository.Create(todo);
         _repository.Save();
         return(Ok());
     }
 }
 public ActionResult Create(ToDoItemVM model)
 {
     try
     {
         var ToDoItem = _mapper.Map<ToDoItem>(model);
         var isSuccess =  _repo.Create(ToDoItem);
         if(!isSuccess)
         {
             ModelState.AddModelError("","Something went wrong");
             return View(model);
         }
         return RedirectToAction(nameof(Index));
     }
     catch
     {
         return View();
     }
 }
Esempio n. 8
0
        public bool AddToDo([FromBody] IEnumerable <ToDoViewModel> toDo)
        {
            if (toDo == null)
            {
                return(false);
                //return BadRequest("Invalid passed data");
            }

            if (!ModelState.IsValid)
            {
                return(false);
                // return BadRequest(ModelState);
            }
            try
            {
                _toDoRepository.Create(_mapper.Map <IEnumerable <ToDoViewModel>, IEnumerable <ToDo> >(toDo));
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 9
0
 public ToDo Create(ToDo toDo)
 {
     return(_repository.Create(toDo));
 }
Esempio n. 10
0
 public JsonResult Create(ToDoDto toDoItem)
 {
     toDoItem = toDoRepository.Create(toDoItem);
     return(Json(toDoItem));
 }
 public int Post([FromBody] ToDoDto toDoDto)
 {
     return(_toDoRepository.Create(toDoDto));
 }
Esempio n. 12
0
 public IActionResult Create(ToDo todo)
 {
     todo = repositoryToDo.GetById(todo.id);
     repositoryToDo.Create(todo);
     return(RedirectToAction("Index"));
 }