Beispiel #1
0
        public async Task <ActionResult> Create(TaskDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                TaskData taskData = new TaskData();

                var config = new MapperConfiguration(cfg => {
                    cfg.CreateMap <TaskDataViewModel, TaskData>();
                });

                var mapper = config.CreateMapper();
                taskData = mapper.Map <TaskData>(model);

                taskData.TaskId     = Guid.NewGuid();
                taskData.UserId     = db.Users.Where(u => u.Email == User.Identity.Name).FirstOrDefault().Id;
                taskData.CustomerId = taskData.UserType == USER_TYPE.Customer ? taskData.UserId : null;
                taskData.VenderId   = taskData.UserType == USER_TYPE.Vendor ? taskData.UserId : null;
                taskData.StateId    = States.PendingRFQ;
                taskData.StateName  = Enum.GetName(typeof(States), States.PendingRFQ);
                taskData.CreateTC   = taskData.UpdateTC = DateTime.UtcNow;
                taskData.UpdateBy   = User.Identity.Name;

                db.TaskDatas.Add(taskData);
                await db.SaveChangesAsync();

                //TempData["Status"] = taskData.StateName;
                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
Beispiel #2
0
        // GET: TaskDatas/Create
        public ActionResult Create()
        {
            TaskDataViewModel model = new TaskDataViewModel();

            return(View(model));
        }
 public TaskDataControl()
 {
     InitializeComponent();
     _viewModel  = new TaskDataViewModel();
     DataContext = _viewModel;
 }