Ejemplo n.º 1
0
        public ServiceResult SaveTask(ObjTask obj)
        {
            try
            {
                var task = Map(obj);
                _taskRepository.Insert(task);
                _taskRepository.SaveChanges();


                //if (obj.RootType == RootTypes.Client)
                //{
                //    var client = _clientRepository.Get(obj.RootId);
                //    client.Credit += obj.Cost * CurrencyConverter.ConvertValute(obj.Currency, CurrencyType.Rub);
                //    _clientRepository.Update(client);
                //    _clientRepository.SaveChanges();
                //}

                return(ServiceResult.SuccessResult(task.Id));
            }
            catch (Exception ex)
            {
                _Logger.LogError(ex.ToString());
                return(ServiceResult.ErrorResult("Ошибка сохранения задачи"));
            }
        }
Ejemplo n.º 2
0
 private void UpdateMap(Task task, ObjTask obj)
 {
     task.Title          = obj.Title;
     task.Description    = obj.Description;
     task.StatusId       = obj.StatusId;
     task.CompeteProcent = obj.CompeteProcent;
     task.DeadLine       = obj.DeadLine;
     task.TaskTypeId     = obj.TaskTypeId;
 }
Ejemplo n.º 3
0
        public IActionResult AddTask(ObjTask obj)
        {
            var result = _taskService.SaveTask(obj);

            if (result.Success)
            {
                return(Json(_taskService.GetTaskList(obj.RootId, obj.RootType)));
            }
            return(Json(result));
        }
Ejemplo n.º 4
0
        public IActionResult TaskAdd(ObjTask obj)
        {
            var result = _taskService.SaveTask(obj);

            if (result.Success)
            {
                return(RedirectToActionOk("Details", "Tasks", new { id = result.Id }, "Задача добавлена"));
            }

            return(RedirectToActionError("TaskAdd", "Ошибка сохранения задачи"));
        }
Ejemplo n.º 5
0
        public IActionResult EditTask(ObjTask obj)
        {
            var result = _taskService.EditTask(obj);

            if (result.Success)
            {
                return(RedirectToActionOk("Details", "Tasks", new { id = result.Id }, "Задача добавлена"));
            }

            return(RedirectToActionError("Details", "Ошибка редактирования задачи"));
        }
Ejemplo n.º 6
0
        private Task Map(ObjTask obj)
        {
            return(new Task
            {
                Id = obj.Id,
                RootId = obj.RootId,
                RootType = obj.RootType,
                Title = obj.Title,
                Description = obj.Description,

                StatusId = obj.StatusId,

                CompeteProcent = obj.CompeteProcent,
                DeadLine = obj.DeadLine,
                TaskTypeId = obj.TaskTypeId,
                UserId = obj.UserId,
            });
        }
Ejemplo n.º 7
0
 public ServiceResult EditTask(ObjTask obj)
 {
     try
     {
         var task = _taskRepository.Get(obj.Id);
         UpdateMap(task, obj);
         _taskRepository.Update(task);
         _taskRepository.SaveChanges();
         //if (obj.RootType == RootTypes.Client)
         //{
         //    var client = _clientRepository.Get(obj.RootId);
         //    client.Credit += (obj.Cost * CurrencyConverter.ConvertValute(obj.Currency, CurrencyType.Rub)) -
         //        (task.Cost * CurrencyConverter.ConvertValute(task.Currency, CurrencyType.Rub));
         //    _clientRepository.Update(client);
         //    _clientRepository.SaveChanges();
         //}
         return(ServiceResult.SuccessResult(obj.Id));
     }
     catch (Exception ex)
     {
         _Logger.LogError("Edit Task error TaskId = {0} : {1}", obj.Id, ex);
         return(ServiceResult.ErrorResult("Ошибка при сохранении задачи"));
     }
 }