示例#1
0
        public async Task <int> AddLocation(LocationDto requestDto)
        {
            try
            {
                var location = new Location
                {
                    Name = requestDto.Name,
                };
                _context.Location.Add(location);
                _context.SaveChanges();

                var branchLocation = new BranchLocation
                {
                    FkBranchId   = requestDto.BranchId,
                    FkLocationId = location.PkLocationId
                };

                _context.BranchLocation.Add(branchLocation);

                return(await Task.FromResult(_context.SaveChanges()));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="requestDto"></param>
 /// <returns></returns>
 public async Task <int> AddEmployeeProfile(EmployeeProfileDto requestDto)
 {
     try
     {
         var employeeProfile = new EmployeeProfile
         {
             FirstName       = requestDto.FirstName,
             LastName        = requestDto.LastName,
             CellPhone       = requestDto.CellPhone,
             City            = requestDto.City,
             DateOfBirth     = requestDto.DateOfBirth,
             HomePhone       = requestDto.HomePhone,
             MiddleInitial   = requestDto.MiddleInitial,
             JobTitle        = requestDto.JobTitle,
             State           = requestDto.State,
             StreetAddress   = requestDto.StreetAddress,
             FkInitiatedById = requestDto.FkInitiatedById,
             WorkEmail       = requestDto.WorkEmail,
             ZipCode         = requestDto.ZipCode,
             FkGenderId      = requestDto.GenderId,
             FkUserId        = requestDto.FkUserId,
             CreatedOn       = DateTime.Now,
         };
         _context.EmployeeProfile.Add(employeeProfile);
         _context.SaveChanges();
         return(await Task.FromResult(employeeProfile.PkEmployeeProfileId));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="requestDto"></param>
        /// <returns></returns>

        /*    public async Task<int> AddBranch(BranchDto requestDto)
         *  {
         *      try
         *      {
         *          var branch = new Branch
         *          {
         *              Name = requestDto.Name,
         *              Address = requestDto.Address,
         *              Email = requestDto.Email,
         *              Phone = requestDto.Phone,
         *              Location=requestDto.Location,
         *              CreatedOn = DateTime.Now,
         *              CompanyBranch = new List<CompanyBranch>
         *
         *              {
         *                  new CompanyBranch
         *                  {
         *                       FkCompanyId = requestDto.CompanyId,
         *
         *
         *                  }
         *
         *              }
         *
         *          };
         *          _context.Branch.Add(branch);
         *          _context.SaveChanges();
         *          return await Task.FromResult(branch.PkBranchId);
         *
         *      }
         *      catch (Exception e)
         *      {
         *          Console.WriteLine(e);
         *          throw;
         *      }
         *  }
         */

        public async Task <int> AddBranch(BranchDto requestDto)
        {
            try
            {
                var branch = new Branch
                {
                    Name      = requestDto.Name,
                    Address   = requestDto.Address,
                    Email     = requestDto.Email,
                    Phone     = requestDto.Phone,
                    Location  = requestDto.Location,
                    CreatedOn = DateTime.Now,
                };

                _context.Branch.Add(branch);
                _context.SaveChanges();

                var CompanyBranch = new CompanyBranch
                {
                    FkCompanyId = requestDto.CompanyId,
                    FkBranchId  = branch.PkBranchId,
                };

                _context.CompanyBranch.Add(CompanyBranch);

                return(await Task.FromResult(_context.SaveChanges()));
            }

            catch (Exception e)

            {
                Console.WriteLine(e);

                throw;
            }
        }