Exemple #1
0
        public async Task <IActionResult> Create(
            [Bind(
                 "Name,Code,CountChanel,IsActiv,IsCommunicationDevice,NumberConnectionPoints,Description,CreatedDate,Id")]
            ModuleType moduleType)
        {
            if (ModelState.IsValid)
            {
                if (moduleType.IsActiv && !moduleType.IsCommunicationDevice)
                {
                    var result = _context.ModulesTypes.Any(x => x.IsActiv && !x.IsCommunicationDevice);
                    if (result)
                    {
                        ModelState.AddModelError(string.Empty, "Уже существует действующий модуль LPBS");
                        return(View(moduleType));
                    }
                }
                if (moduleType.IsCommunicationDevice)
                {
                    moduleType.NumberConnectionPoints = 0;
                }
                _context.Add(moduleType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(moduleType));
        }
Exemple #2
0
        public async Task <T> Add(T entity)
        {
            _context.Entry(entity).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(entity);
        }
        public async Task <IActionResult> Create([Bind("FirstName,MiddleName,LastName,Phone,DepartmentId,Id")]
                                                 EmployeeCreateEditViewModel employee)
        {
            if (ModelState.IsValid)
            {
                var employeeIns = _mapper.Map <EmployeeCreateEditViewModel, Employee>(employee);
                try
                {
                    _context.Add(employeeIns);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateException dbUpdateException)
                {
                    _logger.LogError("{ExceptionMessage}", dbUpdateException.Message);
                    ModelState.AddModelError(String.Empty, "Ошибка при сохранении");
                    //return View(employee);
                }
                catch (Exception e)
                {
                    _logger.LogError("{ExceptionMessage}", e.Message);
                }
            }

            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Name", employee.DepartmentId);
            return(View(employee));
        }
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            _dbContext.Set <TEntity>().Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] Contractor contractor)
        {
            if (ModelState.IsValid)
            {
                if (_context.Statuses.Any(x => String.Equals(x.Name, contractor.Name)))
                {
                    ModelState.AddModelError("Name", "Уже существует");
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Add(contractor);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    catch (DbUpdateException e)
                    {
                        var exception = e.InnerException;
                        if (exception != null && exception.Message.Contains("IX_Contractors_Name"))
                        {
                            ModelState.AddModelError("Name", "Контрагент уже существует");
                        }
                    }
                }
            }

            return(View(contractor));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Description,IsResponsibleProjectsAndSubProjects,IsResponsibleDesignWork")]
                                                 Department department)
        {
            //IX_Departments_Name
            if (ModelState.IsValid)
            {
                if (_context.Departments.Any(x => String.Equals(x.Name, department.Name)))
                {
                    ModelState.AddModelError("Name", "Отдел уже существует");
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Add(department);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    catch (DbUpdateException e)
                    {
                        var exception = e.InnerException;
                        if (exception != null && exception.Message.Contains("IX_Departments_Name"))
                        {
                            ModelState.AddModelError("Name", "Отдел уже существует");
                        }
                    }
                }
            }

            return(View(department));
        }
Exemple #7
0
 protected virtual Task <int> DeleteOneAsync(int id)
 {
     return(Task.Run(async() =>
     {
         var obj = await GetOneAsync(id);
         _efDbContext.Set <T>().Remove(obj);
         return await _efDbContext.SaveChangesAsync();
     }));
 }
Exemple #8
0
        public async Task AddMuseumAsync(EntityMuseum entityMuseum)
        {
            var model = new TableMuseum
            {
                Id   = Guid.NewGuid().GetGuidStr(),
                Name = entityMuseum.Name
            };
            await _context.Museums.AddAsync(model);

            await _context.SaveChangesAsync();
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,AddressLine1,AddressLine2,City,State,Country,Pin")] Agency agency)
        {
            if (ModelState.IsValid)
            {
                db.Agencies.Add(agency);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(agency));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,Title,ReleaseDate,Price")] DemoModel demoModel)
        {
            if (ModelState.IsValid)
            {
                db.DemoModels.Add(demoModel);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(demoModel));
        }
Exemple #11
0
        public async Task <ActionResult> Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(order));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,Name,Date,Amount,Comments,IsPrepared,IsVerified,IsPassed")] VehicleBill vehicleBill)
        {
            if (ModelState.IsValid)
            {
                db.VehicleBills.Add(vehicleBill);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(vehicleBill));
        }
Exemple #13
0
        public async Task SetCompletedAsync(string messageId, CancellationToken cancellationToken = default)
        {
            var outboxMessage = await _dbContext.Set <OutboxMessage>()
                                .FirstOrDefaultAsync(m => m.Id == messageId, cancellationToken: cancellationToken);

            if (outboxMessage == null)
            {
                return;
            }

            outboxMessage.SetCompleted();
            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Exemple #14
0
        public async Task <ActionResult> Create([Bind(Include = "ID,No,Description,Date,AgencyId")] LoaPackage loaPackage)
        {
            if (ModelState.IsValid)
            {
                db.LoaPackages.Add(loaPackage);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.AgencyId = new SelectList(db.Agencies, "ID", "Name", loaPackage.AgencyId);
            return(View(loaPackage));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,LoaPackageId,Name,Date")] LoaAmendment loaAmendment)
        {
            if (ModelState.IsValid)
            {
                db.LoaAmendments.Add(loaAmendment);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.LoaPackageId = new SelectList(db.LoaPackages, "ID", "No", loaAmendment.LoaPackageId);
            return(View(loaAmendment));
        }
        public async Task <bool> AddStudentAsync(AddStudentModel profile)
        {
            try
            {
                DbUser user = new DbUser
                {
                    UserName    = profile.Email /*profile.UserName*/,
                    Email       = profile.Email,
                    PhoneNumber = profile.PhoneNumber,
                };
                BaseProfile prof = new BaseProfile
                {
                    Name               = profile.Name,
                    LastName           = profile.LastName,
                    Surname            = profile.Surname,
                    Adress             = profile.Adress,
                    DateOfBirth        = Convert.ToDateTime(profile.DateOfBirth),
                    PassportString     = profile.PassportString,
                    IdentificationCode = profile.IdentificationCode
                };
                string password = PasswordGenerator.GenerationPassword();
                await _userManager.CreateAsync(user, password);

                await _userManager.AddToRoleAsync(user, "Student");

                prof.Id = user.Id;
                await _context.BaseProfiles.AddAsync(prof);

                await _context.SaveChangesAsync();

                await _context.StudentProfiles.AddAsync(new StudentProfile { Id = prof.Id });

                await _context.SaveChangesAsync();

                if (profile.GroupId != 0)
                {
                    await _context.GroupsToStudents.AddAsync(new GroupToStudent
                    {
                        GroupId   = profile.GroupId,
                        StudentId = user.Id
                    });

                    await _context.SaveChangesAsync();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #17
0
        public async Task <IActionResult> Create(
            [Bind(
                 "Name,SerialNum,CertifiedNum,ProductTypeId,SubProjectId,IsFormed,ManufacturingDate,ShippedDate,OrderDate,ShippedDate,Id,Description")]
            ProductCreateViewModel productDto)
        {
            if (ModelState.IsValid)
            {
                if (_context.Products.Any(x => x.SerialNum == productDto.SerialNum &&
                                          x.SerialNum != null))
                {
                    ModelState.AddModelError("SerialNum", "Серийный номер уже существует");
                }

                if (_context.Products.Any(x => x.CertifiedNum == productDto.CertifiedNum &&
                                          x.CertifiedNum != null))
                {
                    ModelState.AddModelError("CertifiedNum", "Код уже используется");
                }

                if (ModelState.IsValid)
                {
                    var product = _mapper.Map <ProductCreateViewModel, Product>(productDto);
                    _context.Add(product);
                    try
                    {
                        await _context.SaveChangesAsync();

                        return(RedirectToAction("GetProductsForSubProject", new { subProjectId = product.SubProjectId }));
                    }
                    catch (DbUpdateException e)
                    {
                        var exception = e.InnerException;
                        if (exception != null && exception.Message.Contains("IX_Products_SerialNum"))
                        {
                            ModelState.AddModelError("SerialNum", "Такой номер уже используется");
                        }
                        if (exception != null && exception.Message.Contains("IX_Products_CertifiedNum"))
                        {
                            ModelState.AddModelError("CertifiedNum", "Такой номер уже используется");
                        }
                    }
                }
            }

            ViewData["ProductTypeId"] =
                new SelectList(_context.ProductTypes, "Id", "Name", productDto.ProductTypeId);
            // ViewData["SubProjectId"] =
            //     new SelectList(_context.SubProjects, "Id", "Name", productDto.SubProjectId);
            return(View(productDto));
        }
Exemple #18
0
        /// <summary>
        /// Thực hiện nhập khẩu nhân viên
        /// </summary>
        /// <param name="keyImport">Key xác định lấy dữ liệu để nhập khẩu từ cache</param>
        /// <param name="overriderData">Có cho phép ghi đè hay không (true- ghi đè dữ liệu trùng lặp trong db)</param>
        /// <param name="cancellationToken">Tham số tùy chọn xử lý đa luồng (hiện tại chưa sử dụng)</param>
        /// <returns>ActionServiceResult(với các thông tin tương ứng tùy thuộc kết nhập khẩu)</returns>
        /// CreatedBy: NVMANH (10/10/2020)
        public override async Task <ActionServiceResult> Import(string importKey, bool overriderData, CancellationToken cancellationToken)
        {
            var employees = ((List <Employee>)CacheGet(importKey)).Where(e => e.ImportValidState == ImportValidState.Valid || (overriderData && e.ImportValidState == ImportValidState.DuplicateInDb)).ToList();;

            using var dbContext = new EfDbContext();

            // Danh sách các vị trí/ chức vụ mới:
            var newPositons = ((List <Position>)CacheGet(string.Format("Position_{0}", importKey)));
            await dbContext.Position.AddRangeAsync(newPositons);

            // Danh sách nhân viên thêm mới:
            var newEmployees = employees.Where(e => e.ImportValidState == Core.Enumeration.ImportValidState.Valid).ToList();
            await dbContext.Employee.AddRangeAsync(newEmployees);

            // Danh sách nhân viên thực hiện ghi đè:
            var modifiedEmployees = employees.Where(e => e.ImportValidState == Core.Enumeration.ImportValidState.DuplicateInDb).ToList();

            foreach (var emp in modifiedEmployees)
            {
                dbContext.Entry(emp).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                var pbd = dbContext.EmployeeFamily.Where(e => e.EmployeeId == emp.EmployeeId);
                dbContext.EmployeeFamily.AddRange(emp.EmployeeFamily);
                dbContext.EmployeeFamily.RemoveRange(pbd);
            }
            //dbContext.Employee.UpdateRange(modifiedEmployees);
            await dbContext.SaveChangesAsync();

            return(new ActionServiceResult(true, Resources.Msg_ImportSuccess, MISACode.Success, employees));
        }
        public async Task <dynamic> Post([FromBody] UpdateStatus command)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Status status = _mapper.Map <UpdateStatus, Status>(command);
                    _dbContext.Add(status);
                    int result = await _dbContext.SaveChangesAsync();

                    // send event
                    StatusReceived message = Mapper.Map <StatusReceived>(command);
                    await _messagePublisher.PublishMessageAsync(message.MessageType, message, "StatusReceived");

                    //return result
                    return(result > 0 ? new
                    {
                        Saved = true,
                    }
                                        : new
                    {
                        Saved = false,
                    });
                }
                return(BadRequest());
            }

            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemple #20
0
        public async Task <IActionResult> Edit(int id,
                                               [Bind(
                                                    "ModuleTypeId,DestinationOrderCardId,SerialNumber,Place,FirmwareVersion,EmployeeId,ActualOrderCardId,ManufacturingData,Id")]
                                               ModuleCreateEditViewModel moduleVm)
        {
            if (id != moduleVm.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var module = _mapper.Map <ModuleCreateEditViewModel, Module>(moduleVm);

                try
                {
                    _context.Update(module);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModuleExists(module.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(GetModulesForCardOrder),
                                        new { cardOrderId = moduleVm.DestinationOrderCardId }));
            }

            ViewData["EmployeeId"] = new SelectList(_context.Employees
                                                    .Where(x => x.Department.IsResponsibleDesignWork), "Id", "GetFullName");
            ViewData["ActualOrderCardId"] =
                new SelectList(_context.OrderCards, "Id", "Name", moduleVm.ActualOrderCardId);
            ViewData["DestinationOrderCardId"] =
                new SelectList(_context.OrderCards, "Id", "Name", moduleVm.DestinationOrderCardId);
            ViewData["ModuleTypeId"] = new SelectList(_context.ModulesTypes, "Id", "Code", moduleVm.ModuleTypeId);
            return(View(moduleVm));
        }
Exemple #21
0
        public async Task AcquireStatus(UpdateStatus command)
        {
            Status status = _mapper.Map <UpdateStatus, Status>(command);

            _dbContext.Add(status);
            int result = await _dbContext.SaveChangesAsync();

            // send event
            StatusReceived message = Mapper.Map <StatusReceived>(command);
            await _messagePublisher.PublishMessageAsync(message.MessageType, message, "StatusReceived");
        }
Exemple #22
0
        public async Task <T> Add(T domainObject)
        {
            if (_service.Set <T>().Any(x => x.UserId == domainObject.UserId))
            {
                throw new Exception("User already exist");
            }
            await _service.Set <T>().AddAsync(domainObject);

            await _service.SaveChangesAsync();

            return(domainObject);
        }
Exemple #23
0
        public static async Task Initialize(EfDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.Products.Count() == 0)
            {
                //First product
                Product     product = new Product();
                List <Size> size    = new List <Size>();
                size.Add(new Size(SizeOfPruduct.M, 1));
                size.Add(new Size(SizeOfPruduct.L, 1));
                size.Add(new Size(SizeOfPruduct.XL, 1));
                size.Add(new Size(SizeOfPruduct.XXL, 1));

                List <Photos> photosList = new List <Photos>();
                photosList.Add(new Photos(@"\Upload\Photos\2d79fb18-0341-4a14-8da1-f7f3edb90a49.jpg"));
                photosList.Add(new Photos(@"\Upload\Photos\5fb493c8-04b7-4e3d-97d7-bc1cb69dc10a.jpg"));
                product.Photos = photosList;

                product.Name        = "Jeansy damskie Rocks";
                product.Price       = 299;
                product.Description = "Spodnie damskie Rocks<br />Skład:Bawełna<br /><br />Idealnie dopasowane";
                product.Gender      = Gender.Woman;
                product.Group       = Group.Spodnie;
                product.Sizes       = size;
                product.Table       = @"\Upload\Tables\92e81a01-5c46-4687-8a53-5aa182821760.jpg";
                context.Add(product);

                //Second product
                Product     product1 = new Product();
                List <Size> size1    = new List <Size>();
                size1.Add(new Size(SizeOfPruduct.M, 1));
                size1.Add(new Size(SizeOfPruduct.L, 1));
                size1.Add(new Size(SizeOfPruduct.XL, 1));
                size1.Add(new Size(SizeOfPruduct.XXL, 1));

                List <Photos> photosList1 = new List <Photos>();
                photosList1.Add(new Photos(@"\Upload\Photos\4c44be83-44bd-4e89-b2e9-5ebb2b41eded.jpg"));
                photosList1.Add(new Photos(@"\Upload\Photos\41efc1cd-a190-4e7b-a7bd-1e51fcd038db.jpg"));
                photosList1.Add(new Photos(@"\Upload\Photos\87c39856-4d41-494f-beda-a84d3db48857.jpg"));
                product1.Photos = photosList1;

                product1.Name        = "Marynarka męska";
                product1.Price       = 299;
                product1.Description = "Marynarka męska<br />Skład:Bawełna";
                product1.Gender      = Gender.Men;
                product1.Group       = Group.Kurtki;
                product1.Sizes       = size1;
                product1.Table       = @"\Upload\Tables\92e81a01-5c46-4687-8a53-5aa182821760.jpg";
                context.Add(product1);
                await context.SaveChangesAsync();
            }
        }
Exemple #24
0
        public async Task <JsonResult> AddNewProduct([FromBody] AddProduct productToAdd)
        {
            if (ModelState.IsValid)
            {
                List <Size> sizes               = new List <Size>();
                Product     product             = new Product();
                var         quantityWithoutNull = productToAdd.Quantity.Where(x => x != String.Empty).ToArray();

                for (int i = 0; i < productToAdd.Size.Length; i++)
                {
                    sizes.Add(new Size((SizeOfPruduct)Convert.ToInt32(productToAdd.Size[i]), Convert.ToInt32(quantityWithoutNull[i])));
                }

                product.Name        = productToAdd.Name;
                product.Price       = Convert.ToInt32(productToAdd.Price);
                product.Description = productToAdd.Description;
                product.Gender      = (Gender)Convert.ToInt32(productToAdd.Gender);
                product.Group       = (Group)Convert.ToInt32(productToAdd.Group);
                product.Sizes       = sizes;
                List <Photos> photos = new List <Photos>();

                foreach (var item in productToAdd.Photos)
                {
                    photos.Add(new Photos(item));
                }

                product.Photos = photos;
                product.Table  = productToAdd.Table;
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, responseText = "Your message successfuly sent!" }));
            }
            else
            {
                return(Json(new { success = false, responseText = "Your message not sent!" }));
            }
        }
Exemple #25
0
 public async Task <int> CommitAsync()
 {
     try
     {
         // Transaction işlemleri burada ele alınabilir veya Identity Map kurumsal tasarım kalıbı kullanılarak
         // sadece değişen alanları güncellemeyide sağlayabiliriz.
         return(await _context.SaveChangesAsync());
     }
     catch
     {
         // Burada DbEntityValidationException hatalarını handle edebiliriz.
         throw;
     }
 }
        public async Task <IActionResult> PutPerson(int id, Person person)
        {
            person.id = id;
            _context.Entry(person).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #27
0
        public async Task <IActionResult> Create([Bind("Id,Name,OwnerId,Code,EmployeeId,Description")]
                                                 ProjectCreateViewModel projectVM)
        {
            if (ModelState.IsValid)
            {
                var project = _mapper.Map <ProjectCreateViewModel, Project>(projectVM);
                _context.Add(project);
                try
                {
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateException e)
                {
                    var exception = e.InnerException;
                    if (exception != null && exception.Message.Contains("IX_Projects_Name"))
                    {
                        ModelState.AddModelError("Name", "Проект уже существует");
                    }

                    if (exception != null && exception.Message.Contains("IX_Projects_Code"))
                    {
                        ModelState.AddModelError("Code", "Такой код уже используется");
                    }
                }
            }

            ViewData["EmployeeId"] = new SelectList(_context.Employees
                                                    .Where(x => x.Department.IsResponsibleProjectsAndSubProjects),
                                                    "Id", "GetFullName");
            ViewData["OwnerId"] = new SelectList(_context.Owners,
                                                 "Id", "Name",
                                                 projectVM.OwnerId);
            return(View(projectVM));
        }
Exemple #28
0
        public async Task <IActionResult> Create([Bind("Id,Name,StatusTypeId")] Status status)
        {
            //IX_Statuses_Name
            if (ModelState.IsValid)
            {
                if (_context.Statuses.Any(x =>
                                          String.Equals(x.Name, status.Name) &&
                                          x.StatusTypeId == status.StatusTypeId))
                {
                    ModelState.AddModelError("Name", "Такой статус уже существует");
                }

                if (ModelState.IsValid)
                {
                    _context.Add(status);
                    try
                    {
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    catch (DbUpdateException e)
                    {
                        var exception = e.InnerException;
                        if (exception != null && exception.Message.Contains("IX_Statuses_Name"))
                        {
                            ModelState.AddModelError("Name", "Статус уже существует");
                        }
                    }
                }
            }

            ViewData["StatusTypeId"] =
                new SelectList(_context.StatusTypes, "Id", "StatusTypeName", status.StatusTypeId);
            return(View(status));
        }
Exemple #29
0
        public async Task <IActionResult> Create([Bind("Name,ProductSubTypeId,Description,Id")]
                                                 ProductType productType)
        {
            if (ModelState.IsValid)
            {
                if (_context.ProductTypes.Any(x =>
                                              String.Equals(x.Name, productType.Name)))
                {
                    ModelState.AddModelError("Name", "Такой тип уже существует");
                }

                if (ModelState.IsValid)
                {
                    _context.Add(productType);
                    try
                    {
                        _context.Add(productType);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    catch (DbUpdateException e)
                    {
                        var exception = e.InnerException;
                        if (exception != null && exception.Message.Contains("IX_ProductTypes_Name"))
                        {
                            ModelState.AddModelError("Name", "Тип уже существует");
                        }
                    }
                }
            }

            ViewData["ProductSubTypeId"] =
                new SelectList(_context.ProductSubTypes, "Id", "Name", productType.ProductSubTypeId);
            return(View(productType));
        }
        public async Task <IActionResult> Create(
            [Bind("ProjectId,Name,Code,EmployeeId,StatusId,Contract,ContractorId,Description,EndDate")]
            SubProjectCreateEditViewModel subProjectDTO)
        {
            if (ModelState.IsValid)
            {
                var subProject = _mapper.Map <SubProjectCreateEditViewModel, SubProject>(subProjectDTO);
                _context.Add(subProject);
                try
                {
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(GetSubProject), new { projectId = subProjectDTO.ProjectId }));
                }
                catch (DbUpdateException e)
                {
                    var exception = e.InnerException;
                    if (exception != null && exception.Message.Contains("IX_SubProjects_Name"))
                    {
                        ModelState.AddModelError("Name", "Подпроект уже существует");
                    }

                    if (exception != null && exception.Message.Contains("IX_SubProjects_Code"))
                    {
                        ModelState.AddModelError("Code", "Такой код уже используется");
                    }
                }
            }

            ViewData["EmployeeId"] = new SelectList(_context.Employees
                                                    .Where(x => x.Department.IsResponsibleProjectsAndSubProjects), "Id", "GetFullName");
            ViewData["StatusId"] = new SelectList(_context.Statuses
                                                  .Where(x => x.StatusTypeId == 1), "Id", "Name");
            ViewData["ContractorId"] = new SelectList(_context.Contractors, "Id", "Name");
            return(View(subProjectDTO));
        }