public MasterLoginResult GetADMasterLoginByID(long MasterLoginId)
        {
            try
            {
                var _data = (from ML in _Context.ADMasterLogins
                             join MR in _Context.ADMasterRegistrationType on ML.MasterRegistrationTypeId equals MR.MasterRegistrationTypeId
                             join ME in _Context.ADMasterEmployees on ML.MasterRegistrationId equals ME.MasterEmployeeId
                             join SA in _Context.ADMasterSalutations on ME.MasterSalutationId equals SA.MasterSalutationId into SAGroup
                             from SA in SAGroup.DefaultIfEmpty()
                             join MD in _Context.ADMasterDesignations on ME.MasterDesignationId equals MD.MasterDesignationId into MDGroup
                             from MD in MDGroup.DefaultIfEmpty()
                             join DA in _Context.ADMasterDepartments on ME.MasterDepartmentId equals DA.MasterDepartmentId into DAGroup
                             from DA in DAGroup.DefaultIfEmpty()
                             join MB in _Context.ADMasterBranches on ME.MasterBranchId equals MB.MasterBranchId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join MC in _Context.ADMasterCompanies on MB.MasterCompanyId equals MC.MasterCompanyId into MCGroup
                             from MC in MCGroup.DefaultIfEmpty()
                             join MP in _Context.ADMasterProfiles on ML.MasterProfileId equals MP.MasterProfileId
                             where ML.MasterLoginId == MasterLoginId
                             select new
                {
                    ML.MasterLoginId,
                    ML.MasterRegistrationTypeId,
                    ML.MasterRegistrationId,
                    ML.UserName,
                    ML.Password,
                    ML.MasterProfileId,
                    ML.VerificationCode,
                    ML.IsVerified,
                    ML.IsFirstLogin,
                    ML.IsActive,
                    MR.MasterRegistrationTypeTitle,
                    ME.EmployeeName,
                    MP.ProfileTitle,
                    SA.SalutationTitle,
                    MD.DesignationTitle,
                    DA.DepartmentTitle,
                    MB.BranchTitle,
                    MC.CompanyTitle
                });

                var _Item = _data.FirstOrDefault();

                MasterLoginResult _objMasterLoginResult = new MasterLoginResult();

                if (_Item != null)
                {
                    _objMasterLoginResult.MasterLoginId            = _Item.MasterLoginId;
                    _objMasterLoginResult.MasterRegistrationTypeId = _Item.MasterRegistrationTypeId;
                    _objMasterLoginResult.RegistrationTypeTitle    = _Item.MasterRegistrationTypeTitle;
                    _objMasterLoginResult.MasterRegistrationId     = _Item.MasterRegistrationId;
                    _objMasterLoginResult.RegistrationTitle        = _Item.EmployeeName;
                    _objMasterLoginResult.SalutationTitle          = _Item.SalutationTitle;
                    _objMasterLoginResult.DesignationTitle         = _Item.DesignationTitle;
                    _objMasterLoginResult.DepartmentTitle          = _Item.DepartmentTitle;
                    _objMasterLoginResult.BranchTitle  = _Item.BranchTitle;
                    _objMasterLoginResult.CompanyTitle = _Item.CompanyTitle;

                    _objMasterLoginResult.UserName         = _Item.UserName;
                    _objMasterLoginResult.Password         = _Item.Password;
                    _objMasterLoginResult.MasterProfileId  = _Item.MasterProfileId;
                    _objMasterLoginResult.ProfileTitle     = _Item.ProfileTitle;
                    _objMasterLoginResult.VerificationCode = _Item.VerificationCode;
                    _objMasterLoginResult.IsVerified       = _Item.IsVerified;
                    _objMasterLoginResult.IsFirstLogin     = _Item.IsFirstLogin;
                    _objMasterLoginResult.IsActive         = _Item.IsActive;
                }

                return(_objMasterLoginResult);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        public MasterEmployeeResult GetADMasterEmployeeByID(long MasterEmployeeId)
        {
            try
            {
                var _data = (from ME in _Context.ADMasterEmployees
                             join SA in _Context.ADMasterSalutations on ME.MasterSalutationId equals SA.MasterSalutationId into SAGroup
                             from SA in SAGroup.DefaultIfEmpty()
                             join MG in _Context.ADMasterGenders on ME.Gender equals MG.MasterGenderId into MGGroup
                             from MG in MGGroup.DefaultIfEmpty()
                             join MD in _Context.ADMasterDesignations on ME.MasterDesignationId equals MD.MasterDesignationId into MDGroup
                             from MD in MDGroup.DefaultIfEmpty()
                             join DA in _Context.ADMasterDepartments on ME.MasterDepartmentId equals DA.MasterDepartmentId into DAGroup
                             from DA in DAGroup.DefaultIfEmpty()
                             join ME2 in _Context.ADMasterEmployees on ME.ReportingHeadId equals ME2.MasterEmployeeId into ME2Group
                             from ME2 in ME2Group.DefaultIfEmpty()
                             join MD2 in _Context.ADMasterDesignations on ME2.MasterDesignationId equals MD2.MasterDesignationId into MD2Group
                             from MD2 in MD2Group.DefaultIfEmpty()
                             join ET in _Context.ADMasterEmployeeTypes on ME.MasterEmployeeTypeId equals ET.MasterEmployeeTypeId into ETGroup
                             from ET in ETGroup.DefaultIfEmpty()
                             join TZ in _Context.ADMasterTimeZones on ME.MasterTimeZoneId equals TZ.MasterTimeZoneId into TZGroup
                             from TZ in TZGroup.DefaultIfEmpty()
                             join ES in _Context.ADMasterEmployeeStatus on ME.MasterEmployeeStatusId equals ES.MasterEmployeeStatusId into ESGroup
                             from ES in ESGroup.DefaultIfEmpty()
                             join CC in _Context.ADMasterCountries on ME.MasterCountryId equals CC.MasterCountryId into CCGroup
                             from CC in CCGroup.DefaultIfEmpty()
                             join MS in _Context.ADMasterStates on ME.MasterStateId equals MS.MasterStateId into MSGroup
                             from MS in MSGroup.DefaultIfEmpty()
                             join PT in _Context.ADMasterPaymentTypes on ME.MasterPaymentTypeId equals PT.MasterPaymentTypeId into PTGroup
                             from PT in PTGroup.DefaultIfEmpty()
                             join BA in _Context.ADMasterBankAccountTypes on ME.MasterBankAccountTypeId equals BA.MasterBankAccountTypeId into BAGroup
                             from BA in BAGroup.DefaultIfEmpty()
                             join MB in _Context.ADMasterBranches on ME.MasterBranchId equals MB.MasterBranchId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join MC in _Context.ADMasterCompanies on MB.MasterCompanyId equals MC.MasterCompanyId into MCGroup
                             from MC in MCGroup.DefaultIfEmpty()
                             where ME.MasterEmployeeId == MasterEmployeeId
                             select new
                {
                    ME.MasterEmployeeId,
                    ME.EmployeeCode,
                    ME.MasterSalutationId,
                    SA.SalutationTitle,
                    ME.EmployeeName,
                    ME.DateOfBirth,
                    ME.DateOfJoining,
                    ME.Gender,
                    MG.GenderTitle,
                    ME.PANNo,
                    ME.AadhaarNo,
                    ME.MasterDesignationId,
                    MD.DesignationTitle,
                    ME.MasterDepartmentId,
                    DA.DepartmentTitle,
                    ME.ReportingHeadId,
                    ReportingHeadTitle = ME2.EmployeeName,
                    ReportingHeadDesignationTitle = MD2.DesignationTitle,
                    ME.MasterEmployeeTypeId,
                    ET.EmployeeTypeTitle,
                    ME.MasterTimeZoneId,
                    TZ.TimeZoneTitle,
                    ME.MasterEmployeeStatusId,
                    ES.EmployeeStatusTitle,
                    ME.DateOfLeavingOrganisation,
                    ME.Address1,
                    ME.Address2,
                    ME.MasterCountryId,
                    CC.CountryTitle,
                    ME.MasterStateId,
                    MS.StateTitle,
                    ME.City,
                    ME.PinCode,
                    ME.PhoneNumber,
                    ME.MobileNumber,
                    ME.Email,
                    ME.MasterPaymentTypeId,
                    PT.MasterPaymentTitle,
                    ME.PaypalID,
                    ME.PaypalLink,
                    ME.IsPaypalAccountVerified,
                    ME.MasterBankAccountTypeId,
                    BA.MasterBankAccountTypeTitle,
                    ME.BankName,
                    ME.BankAccountNumber,
                    ME.IFCSCode,
                    ME.ShiftCode_RoutingNo_IBAN,
                    ME.BankBranch,
                    ME.BankCity,
                    ME.BankAddress,
                    ME.UploadBankDetail,
                    ME.IsBankAccountVerified,
                    ME.MasterBranchId,
                    MB.BranchTitle,
                    MB.MasterCompanyId,
                    MC.CompanyTitle,
                    MC.CompanyLogo,
                    ME.IsActive
                });


                var _Item = _data.Where(a => a.MasterEmployeeId == MasterEmployeeId).FirstOrDefault();;

                MasterEmployeeResult _MasterEmployeeResult = new MasterEmployeeResult();
                if (_data != null)
                {
                    _MasterEmployeeResult.MasterEmployeeId   = _Item.MasterEmployeeId;
                    _MasterEmployeeResult.EmployeeCode       = _Item.EmployeeCode;
                    _MasterEmployeeResult.MasterSalutationId = _Item.MasterSalutationId;
                    _MasterEmployeeResult.SalutationTitle    = _Item.SalutationTitle;
                    _MasterEmployeeResult.EmployeeName       = _Item.EmployeeName;
                    _MasterEmployeeResult.DateOfJoining      = _Item.DateOfJoining;
                    _MasterEmployeeResult.DateOfBirth        = _Item.DateOfBirth;
                    _MasterEmployeeResult.Gender             = _Item.Gender;
                    _MasterEmployeeResult.GenderTitle        = _Item.GenderTitle;
                    _MasterEmployeeResult.PANNo                         = _Item.PANNo;
                    _MasterEmployeeResult.AadhaarNo                     = _Item.AadhaarNo;
                    _MasterEmployeeResult.MasterDesignationId           = _Item.MasterDesignationId;
                    _MasterEmployeeResult.DesignationTitle              = _Item.DesignationTitle;
                    _MasterEmployeeResult.MasterDepartmentId            = _Item.MasterDepartmentId;
                    _MasterEmployeeResult.DepartmentTitle               = _Item.DepartmentTitle;
                    _MasterEmployeeResult.ReportingHeadId               = _Item.ReportingHeadId;
                    _MasterEmployeeResult.ReportingHeadTitle            = _Item.ReportingHeadTitle;
                    _MasterEmployeeResult.ReportingHeadDesignationTitle = _Item.ReportingHeadDesignationTitle;
                    _MasterEmployeeResult.MasterEmployeeTypeId          = _Item.MasterEmployeeTypeId;
                    _MasterEmployeeResult.EmployeeTypeTitle             = _Item.EmployeeTypeTitle;
                    _MasterEmployeeResult.MasterTimeZoneId              = _Item.MasterTimeZoneId;
                    _MasterEmployeeResult.TimeZoneTitle                 = _Item.TimeZoneTitle;
                    _MasterEmployeeResult.MasterEmployeeStatusId        = _Item.MasterEmployeeStatusId;
                    _MasterEmployeeResult.EmployeeStatusTitle           = _Item.EmployeeStatusTitle;
                    _MasterEmployeeResult.DateOfLeavingOrganisation     = _Item.DateOfLeavingOrganisation;
                    _MasterEmployeeResult.Address1                      = _Item.Address1;
                    _MasterEmployeeResult.Address2                      = _Item.Address2;
                    _MasterEmployeeResult.MasterCountryId               = _Item.MasterCountryId;
                    _MasterEmployeeResult.CountryTitle                  = _Item.CountryTitle;
                    _MasterEmployeeResult.MasterStateId                 = _Item.MasterStateId;
                    _MasterEmployeeResult.StateTitle                    = _Item.StateTitle;
                    _MasterEmployeeResult.City                     = _Item.City;
                    _MasterEmployeeResult.PinCode                  = _Item.PinCode;
                    _MasterEmployeeResult.MobileNumber             = _Item.MobileNumber;
                    _MasterEmployeeResult.PhoneNumber              = _Item.PhoneNumber;
                    _MasterEmployeeResult.Email                    = _Item.Email;
                    _MasterEmployeeResult.MasterPaymentTypeId      = _Item.MasterPaymentTypeId;
                    _MasterEmployeeResult.PaymentTypeTitle         = _Item.MasterPaymentTitle;
                    _MasterEmployeeResult.PaypalID                 = _Item.PaypalID;
                    _MasterEmployeeResult.PaypalLink               = _Item.PaypalLink;
                    _MasterEmployeeResult.IsPaypalAccountVerified  = _Item.IsPaypalAccountVerified;
                    _MasterEmployeeResult.MasterBankAccountTypeId  = _Item.MasterBankAccountTypeId;
                    _MasterEmployeeResult.BankName                 = _Item.BankName;
                    _MasterEmployeeResult.BankAccountNumber        = _Item.BankAccountNumber;
                    _MasterEmployeeResult.IFCSCode                 = _Item.IFCSCode;
                    _MasterEmployeeResult.ShiftCode_RoutingNo_IBAN = _Item.ShiftCode_RoutingNo_IBAN;
                    _MasterEmployeeResult.BankBranch               = _Item.BankBranch;
                    _MasterEmployeeResult.BankCity                 = _Item.BankCity;
                    _MasterEmployeeResult.BankAddress              = _Item.BankAddress;
                    _MasterEmployeeResult.UploadBankDetail         = _Item.UploadBankDetail;
                    _MasterEmployeeResult.IsBankAccountVerified    = _Item.IsBankAccountVerified;
                    _MasterEmployeeResult.MasterBranchId           = _Item.MasterBranchId;
                    _MasterEmployeeResult.BranchTitle              = _Item.BranchTitle;
                    _MasterEmployeeResult.MasterCompanyId          = _Item.MasterCompanyId;
                    _MasterEmployeeResult.CompanyTitle             = _Item.CompanyTitle;
                    _MasterEmployeeResult.CompanyLogo              = _Item.CompanyLogo;

                    _MasterEmployeeResult.IsActive    = _Item.IsActive;
                    _MasterEmployeeResult.ActiveColor = "green";
                    _MasterEmployeeResult.ActiveIcon  = "glyphicon glyphicon-ok";

                    if (_MasterEmployeeResult.IsActive == false)
                    {
                        _MasterEmployeeResult.ActiveColor = "red";
                        _MasterEmployeeResult.ActiveIcon  = "glyphicon glyphicon-remove";
                    }
                }

                return(_MasterEmployeeResult);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public IEnumerable <MasterLoginResult> GetAllADMasterLogin()
        {
            try
            {
                var _data = (from ML in _Context.ADMasterLogins
                             join MR in _Context.ADMasterRegistrationType on ML.MasterRegistrationTypeId equals MR.MasterRegistrationTypeId
                             join ME in _Context.ADMasterEmployees on ML.MasterRegistrationId equals ME.MasterEmployeeId
                             join SA in _Context.ADMasterSalutations on ME.MasterSalutationId equals SA.MasterSalutationId into SAGroup
                             from SA in SAGroup.DefaultIfEmpty()
                             join MD in _Context.ADMasterDesignations on ME.MasterDesignationId equals MD.MasterDesignationId into MDGroup
                             from MD in MDGroup.DefaultIfEmpty()
                             join DA in _Context.ADMasterDepartments on ME.MasterDepartmentId equals DA.MasterDepartmentId into DAGroup
                             from DA in DAGroup.DefaultIfEmpty()
                             join MB in _Context.ADMasterBranches on ME.MasterBranchId equals MB.MasterBranchId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join MC in _Context.ADMasterCompanies on MB.MasterCompanyId equals MC.MasterCompanyId into MCGroup
                             from MC in MCGroup.DefaultIfEmpty()
                             join MP in _Context.ADMasterProfiles on ML.MasterProfileId equals MP.MasterProfileId
                             select new {
                    ML.MasterLoginId, ML.MasterRegistrationTypeId, ML.MasterRegistrationId, ML.UserName, ML.Password, ML.MasterProfileId,
                    ML.VerificationCode, ML.IsVerified, ML.IsFirstLogin, ML.IsActive,
                    MR.MasterRegistrationTypeTitle,
                    ME.EmployeeName,
                    MP.ProfileTitle,
                    SA.SalutationTitle,
                    MD.DesignationTitle,
                    DA.DepartmentTitle,
                    MB.BranchTitle,
                    MC.CompanyTitle
                });

                List <MasterLoginResult> objMasterLoginResultList = new List <MasterLoginResult>();
                foreach (var _Item in _data)
                {
                    MasterLoginResult _objMasterLoginResult = new MasterLoginResult();

                    _objMasterLoginResult.MasterLoginId            = _Item.MasterLoginId;
                    _objMasterLoginResult.MasterRegistrationTypeId = _Item.MasterRegistrationTypeId;
                    _objMasterLoginResult.RegistrationTypeTitle    = _Item.MasterRegistrationTypeTitle;
                    _objMasterLoginResult.MasterRegistrationId     = _Item.MasterRegistrationId;
                    _objMasterLoginResult.RegistrationTitle        = _Item.EmployeeName;
                    _objMasterLoginResult.SalutationTitle          = _Item.SalutationTitle;
                    _objMasterLoginResult.DesignationTitle         = _Item.DesignationTitle;
                    _objMasterLoginResult.DepartmentTitle          = _Item.DepartmentTitle;
                    _objMasterLoginResult.BranchTitle  = _Item.BranchTitle;
                    _objMasterLoginResult.CompanyTitle = _Item.CompanyTitle;

                    _objMasterLoginResult.UserName         = _Item.UserName;
                    _objMasterLoginResult.Password         = _Item.Password;
                    _objMasterLoginResult.MasterProfileId  = _Item.MasterProfileId;
                    _objMasterLoginResult.ProfileTitle     = _Item.ProfileTitle;
                    _objMasterLoginResult.VerificationCode = _Item.VerificationCode;
                    _objMasterLoginResult.IsVerified       = _Item.IsVerified;
                    _objMasterLoginResult.IsFirstLogin     = _Item.IsFirstLogin;
                    _objMasterLoginResult.IsActive         = _Item.IsActive;

                    objMasterLoginResultList.Add(_objMasterLoginResult);
                }

                return(objMasterLoginResultList.ToList());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 4
0
        public IEnumerable <MasterProductResult> GetASMasterProductByID(long MasterCategoryId, long MasterSubCategoryId, long MasterBrandId)
        {
            try
            {
                //Get Parent Product data as per MasterCategoryId Or MasterSubCategoryId Or  MasterBranchId
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             where (MasterCategoryId > 0 && MasterSubCategoryId == 0 && MasterBrandId == 0 && SC.MasterCategoryId == MasterCategoryId) ||
                             (MasterCategoryId == 0 && MasterSubCategoryId > 0 && MasterBrandId == 0 && MP.MasterSubCategoryId == MasterSubCategoryId) ||
                             (MasterCategoryId == 0 && MasterSubCategoryId == 0 && MasterBrandId > 0 && MP.MasterBrandId == MasterBrandId)
                             select new
                {
                    MP.MasterProductId,
                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.ProductHSNCode,
                    MP.ProductBarCode,
                    MP.ProductMainImage,
                    MP.Description,
                    MP.Specification,
                    MP.LegalDisclamer,
                    MP.SafetyWarning,
                    MP.ProductModel,
                    MP.Manufacturer,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.CountryOfOrigin,
                    //CO.CountryTitle,
                    MP.ProductTaxCode,
                    //MT.TaxTitle,
                    //MT.IsTaxPercentageAmount,
                    //MT.TaxValue,
                    MP.ProductCurrency,
                    //MC.CurrencyTitle,
                    MP.Sequence,
                    MP.IsActive,
                    MP.EnterById,
                    MP.EnterDate,
                    MP.ModifiedById,
                    MP.ModifiedDate,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    CA.CategoryTitle,
                    CA.MasterCategoryId
                });

                var _AdminCountries  = _AdminContext.ADMasterCountries.ToList();
                var _AdminTaxes      = _AdminContext.ADMasterTaxes.ToList();
                var _AdminCurrencies = _AdminContext.ADMasterCurrencies.ToList();
                var _AdminBranches   = _AdminContext.ADMasterBranches.ToList();
                var _AdminEmployees  = _AdminContext.ADMasterEmployees.ToList();
                var _AdminVendors    = _AdminContext.ADMasterVendors.ToList();

                //Get Child Product data as per MasterCategoryId Or MasterSubCategoryId Or  MasterBranchId
                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    where (MasterCategoryId > 0 && MasterSubCategoryId == 0 && MasterBrandId == 0 && MSC.MasterCategoryId == MasterCategoryId) ||
                                    (MasterCategoryId == 0 && MasterSubCategoryId > 0 && MasterBrandId == 0 && MP.MasterSubCategoryId == MasterSubCategoryId) ||
                                    (MasterCategoryId == 0 && MasterSubCategoryId == 0 && MasterBrandId > 0 && MP.MasterBrandId == MasterBrandId)
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.MasterProductId,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                //insert search data in model List<MasterProductResult> object with parent and child
                List <MasterProductResult> objMasterProductResultList = new List <MasterProductResult>();

                foreach (var _Item in _data.ToList())
                {
                    MasterProductResult _MasterProductResult = new MasterProductResult();
                    _MasterProductResult.MasterProductId      = _Item.MasterProductId;
                    _MasterProductResult.ProductTitle         = _Item.ProductTitle;
                    _MasterProductResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterProductResult.BrandTitle           = _Item.BrandTitle;
                    _MasterProductResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterProductResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterProductResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterProductResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterProductResult.ProductSKU           = _Item.ProductSKU;
                    _MasterProductResult.ProductHSNCode       = _Item.ProductHSNCode;
                    _MasterProductResult.ProductBarCode       = _Item.ProductBarCode;
                    _MasterProductResult.ProductMainImage     = _Item.ProductMainImage;
                    _MasterProductResult.Description          = _Item.Description;
                    _MasterProductResult.Specification        = _Item.Specification;
                    _MasterProductResult.LegalDisclamer       = _Item.LegalDisclamer;
                    _MasterProductResult.SafetyWarning        = _Item.SafetyWarning;
                    _MasterProductResult.ProductModel         = _Item.ProductModel;
                    _MasterProductResult.Manufacturer         = _Item.Manufacturer;
                    _MasterProductResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterProductResult.ReorderLevel         = _Item.ReorderLevel;
                    _MasterProductResult.CountryOfOrigin      = _Item.CountryOfOrigin;
                    _MasterProductResult.CountryOfOriginTitle = _AdminCountries.Where(a => a.MasterCountryId == _Item.CountryOfOrigin).Select(a => a.CountryTitle).FirstOrDefault();
                    _MasterProductResult.ProductTaxCode       = _Item.ProductTaxCode;
                    _MasterProductResult.ProductTaxCodeTitle  = _AdminTaxes.Where(a => a.MasterTaxId == _Item.ProductTaxCode).Select(a => a.TaxTitle).FirstOrDefault();
                    _MasterProductResult.ProductCurrency      = _Item.ProductCurrency;
                    _MasterProductResult.ProductCurrencyTitle = _AdminCurrencies.Where(a => a.MasterCurrencyId == _Item.ProductCurrency).Select(a => a.CurrencyTitle).FirstOrDefault();;

                    _MasterProductResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsAssign                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterProductResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsInSold                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterProductResult.AssetsInDead                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterProductResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterProductResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);

                    _MasterProductResult.Sequence      = _Item.Sequence;
                    _MasterProductResult.IsActive      = _Item.IsActive;
                    _MasterProductResult.EnterById     = _Item.EnterById;
                    _MasterProductResult.EnterDate     = _Item.EnterDate;
                    _MasterProductResult.ModifiedById  = _Item.ModifiedById;
                    _MasterProductResult.ModifiedDate  = _Item.ModifiedDate;
                    _MasterProductResult.MaxProductSKU = _Context.ASMasterProductChilds.Where(a => a.MasterProductId == _Item.MasterProductId).Max(a => a.ProductChildSKU);

                    objMasterProductResultList.Add(_MasterProductResult);

                    var _dataChild = (from MPC in _Context.ASMasterProductChilds
                                      join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId into MAAGroup
                                      from MAA in MAAGroup.DefaultIfEmpty()
                                      where MPC.MasterProductId == _Item.MasterProductId
                                      select new
                    {
                        MPC.MasterProductChildId,
                        MPC.MasterProductId,
                        MPC.ProductChildSKU,
                        MPC.ManufacturerPartNumber,
                        MPC.PurchaseDate,
                        MPC.PurchasePrice,
                        MPC.DepreciatePrice,
                        MPC.WarrantyExpiryDate,
                        MPC.WarrantyStartDate,
                        MPC.IterationOfWarranty,
                        MPC.MasterBranchId,
                        MPC.MasterEmployeeId,
                        MPC.MasterVendorId,
                        MPC.IsDeadAssets,
                        MPC.IsSaleProduct,
                        MPC.IsActive,
                        MasterAssetsAssignmentId = (MAA.MasterAssetsAssignmentId != null ? MAA.MasterAssetsAssignmentId : 0),
                        MAA.AssetsAssignmentDate,
                        MAA.IsAssetsDeAssign
                    });


                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    List <MasterProductAssignChildResult> objMasterProductAssignChildResultList = new List <MasterProductAssignChildResult>();
                    foreach (var _ItemChild in _dataChild.ToList())
                    {
                        MasterProductAssignChildResult _MasterProductAssignChildResult = new MasterProductAssignChildResult();

                        _MasterProductAssignChildResult.MasterProductChildId   = _ItemChild.MasterProductChildId;
                        _MasterProductAssignChildResult.MasterProductId        = _ItemChild.MasterProductId;
                        _MasterProductAssignChildResult.ProductChildSKU        = _ItemChild.ProductChildSKU;
                        _MasterProductAssignChildResult.ManufacturerPartNumber = _ItemChild.ManufacturerPartNumber;
                        _MasterProductAssignChildResult.PurchaseDate           = _ItemChild.PurchaseDate;
                        _MasterProductAssignChildResult.PurchasePrice          = _ItemChild.PurchasePrice;
                        _MasterProductAssignChildResult.DepreciatePrice        = _ItemChild.DepreciatePrice;
                        _MasterProductAssignChildResult.WarrantyExpiryDate     = _ItemChild.WarrantyExpiryDate;
                        _MasterProductAssignChildResult.WarrantyStartDate      = _ItemChild.WarrantyStartDate;
                        _MasterProductAssignChildResult.IterationOfWarranty    = _ItemChild.IterationOfWarranty;
                        _MasterProductAssignChildResult.IsActive                 = _ItemChild.IsActive;
                        _MasterProductAssignChildResult.IsDeadAssets             = _ItemChild.IsDeadAssets;
                        _MasterProductAssignChildResult.IsSaleProduct            = _ItemChild.IsSaleProduct;
                        _MasterProductAssignChildResult.MasterBranchId           = _ItemChild.MasterBranchId;
                        _MasterProductAssignChildResult.BranchTitle              = _AdminBranches.Where(a => a.MasterBranchId == _ItemChild.MasterBranchId).Select(a => a.BranchTitle).FirstOrDefault();
                        _MasterProductAssignChildResult.MasterEmployeeId         = _ItemChild.MasterEmployeeId;
                        _MasterProductAssignChildResult.EmployeeName             = _AdminEmployees.Where(a => a.MasterEmployeeId == _ItemChild.MasterEmployeeId).Select(a => a.EmployeeName).FirstOrDefault();
                        _MasterProductAssignChildResult.MasterAssetsAssignmentId = _ItemChild.MasterAssetsAssignmentId;
                        _MasterProductAssignChildResult.AssetsAssignmentDate     = _ItemChild.AssetsAssignmentDate;
                        _MasterProductAssignChildResult.MasterVendorId           = _ItemChild.MasterVendorId;
                        _MasterProductAssignChildResult.VendorTitle              = _AdminVendors.Where(a => a.MasterVendorId == _ItemChild.MasterVendorId).Select(a => a.VendorTitle).FirstOrDefault();;
                        _MasterProductAssignChildResult.IsAssetsDeAssign         = _ItemChild.IsAssetsDeAssign;

                        objMasterProductAssignChildResultList.Add(_MasterProductAssignChildResult);
                    }
                    _MasterProductResult.ProductAssignChildList = objMasterProductAssignChildResultList;
                }

                return(objMasterProductResultList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 5
0
        public IEnumerable <MasterProductResult> GetAllASMasterProduct()
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             select new
                {
                    MP.MasterProductId,
                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.ProductHSNCode,
                    MP.ProductBarCode,
                    MP.ProductMainImage,
                    MP.Description,
                    MP.Specification,
                    MP.LegalDisclamer,
                    MP.SafetyWarning,
                    MP.ProductModel,
                    MP.Manufacturer,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.CountryOfOrigin,
                    //CO.CountryTitle,
                    MP.ProductTaxCode,
                    //MT.TaxTitle,
                    //MT.IsTaxPercentageAmount,
                    //MT.TaxValue,
                    MP.ProductCurrency,
                    //MC.CurrencyTitle,
                    MP.Sequence,
                    MP.IsActive,
                    MP.EnterById,
                    MP.EnterDate,
                    MP.ModifiedById,
                    MP.ModifiedDate,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    CA.CategoryTitle,
                    CA.MasterCategoryId
                    //TotalAssets = 2,
                    //AssetsAllocated = 1
                }).ToList();

                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.MasterProductId,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                var _AdminCountries  = _AdminContext.ADMasterCountries.ToList();
                var _AdminTaxes      = _AdminContext.ADMasterTaxes.ToList();
                var _AdminCurrencies = _AdminContext.ADMasterCurrencies.ToList();

                List <MasterProductResult> objMasterProductResultList = new List <MasterProductResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _MasterProductResult = new MasterProductResult();

                    _MasterProductResult.MasterProductId      = _Item.MasterProductId;
                    _MasterProductResult.ProductTitle         = _Item.ProductTitle;
                    _MasterProductResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterProductResult.BrandTitle           = _Item.BrandTitle;
                    _MasterProductResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterProductResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterProductResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterProductResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterProductResult.ProductSKU           = _Item.ProductSKU;
                    _MasterProductResult.ProductHSNCode       = _Item.ProductHSNCode;
                    _MasterProductResult.ProductBarCode       = _Item.ProductBarCode;
                    _MasterProductResult.ProductMainImage     = _Item.ProductMainImage;
                    _MasterProductResult.Description          = _Item.Description;
                    _MasterProductResult.Specification        = _Item.Specification;
                    _MasterProductResult.LegalDisclamer       = _Item.LegalDisclamer;
                    _MasterProductResult.SafetyWarning        = _Item.SafetyWarning;
                    _MasterProductResult.ProductModel         = _Item.ProductModel;
                    _MasterProductResult.Manufacturer         = _Item.Manufacturer;
                    _MasterProductResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterProductResult.ReorderLevel         = _Item.ReorderLevel;
                    _MasterProductResult.CountryOfOrigin      = _Item.CountryOfOrigin;
                    _MasterProductResult.CountryOfOriginTitle = _AdminCountries.Where(a => a.MasterCountryId == _Item.CountryOfOrigin).Select(a => a.CountryTitle).FirstOrDefault();
                    _MasterProductResult.ProductTaxCode       = _Item.ProductTaxCode;
                    _MasterProductResult.ProductTaxCodeTitle  = _AdminTaxes.Where(a => a.MasterTaxId == _Item.ProductTaxCode).Select(a => a.TaxTitle).FirstOrDefault();
                    _MasterProductResult.ProductCurrency      = _Item.ProductCurrency;
                    _MasterProductResult.ProductCurrencyTitle = _AdminCurrencies.Where(a => a.MasterCurrencyId == _Item.ProductCurrency).Select(a => a.CurrencyTitle).FirstOrDefault();;
                    _MasterProductResult.Sequence             = _Item.Sequence;

                    _MasterProductResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsAssign                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterProductResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsInSold                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterProductResult.AssetsInDead                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterProductResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterProductResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);


                    _MasterProductResult.IsActive     = _Item.IsActive;
                    _MasterProductResult.EnterById    = _Item.EnterById;
                    _MasterProductResult.EnterDate    = _Item.EnterDate;
                    _MasterProductResult.ModifiedById = _Item.ModifiedById;
                    _MasterProductResult.ModifiedDate = _Item.ModifiedDate;

                    objMasterProductResultList.Add(_MasterProductResult);
                }
                return(objMasterProductResultList.ToList());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public MasterAssetsAssignmentResult GetASMasterAssetsAssignmentByID(long MasterAssetsAssignmentId)
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             //join CO in _AdminContext.ADMasterCountries on MP.CountryOfOrigin equals CO.MasterCountryId into COGroup
                             //from CO in COGroup.DefaultIfEmpty()
                             //join MT in _AdminContext.ADMasterTaxes on MP.ProductTaxCode equals MT.MasterTaxId into MTGroup
                             //from MT in MTGroup.DefaultIfEmpty()
                             //join MC in _AdminContext.ADMasterCurrencies on MP.ProductCurrency equals MC.MasterCurrencyId into MCGroup
                             //from MC in MCGroup.DefaultIfEmpty()
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId
                             join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId
                             where MAA.MasterAssetsAssignmentId == MasterAssetsAssignmentId
                             select new
                {
                    MPC.MasterProductChildId,
                    MPC.MasterProductId,
                    MPC.ProductChildSKU,
                    MPC.ProductChildTitle,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchaseDate,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.MasterVendorId,
                    MPC.IsDeadAssets,
                    MPC.IsTimeToSaleProduct,
                    MPC.IsSaleProduct,
                    MPC.SaleDate,
                    MPC.SalePrice,
                    MPC.ProductQty,
                    MPC.ProductQtyUnit,
                    MPC.NumberOfItemIncludeInProduct,
                    MPC.ItemPackageQuantity,
                    MPC.IterationOfWarranty,
                    MPC.WarrantyStartDate,
                    MPC.WarrantyExpiryDate,
                    MPC.MasterBranchId,

                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    CA.MasterCategoryId,
                    CA.CategoryTitle,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.ProductModel,
                    MP.Manufacturer,

                    MAA.MasterAssetsAssignmentId,
                    MAA.AssetsAssignmentDate,
                    MAA.ASMasterProductChilds,
                    MAA.MasterEmployeeId,
                    MAA.IsAssetsDeAssign,
                    MAA.AssetsDeAssignmentDate,
                    MAA.DeAssignReason,
                    MAA.MasterLocationId,
                    MAA.Sequence,
                    MAA.IsActive,
                    MAA.EnterById,
                    MAA.EnterDate,
                    MAA.ModifiedById,
                    MAA.ModifiedDate,
                });


                var _Item = _data.FirstOrDefault();

                MasterAssetsAssignmentResult _MasterAssetsAssignmentResult = new MasterAssetsAssignmentResult();
                if (_data != null)
                {
                    _MasterAssetsAssignmentResult.MasterAssetsAssignmentId = _Item.MasterAssetsAssignmentId;
                    _MasterAssetsAssignmentResult.AssetsAssignmentDate     = _Item.AssetsAssignmentDate;
                    _MasterAssetsAssignmentResult.MasterEmployeeId         = _Item.MasterEmployeeId;
                    _MasterAssetsAssignmentResult.IsAssetsDeAssign         = _Item.IsAssetsDeAssign;
                    _MasterAssetsAssignmentResult.AssetsDeAssignmentDate   = _Item.AssetsDeAssignmentDate;
                    _MasterAssetsAssignmentResult.DeAssignReason           = _Item.DeAssignReason;
                    _MasterAssetsAssignmentResult.MasterLocationId         = _Item.MasterLocationId;
                    _MasterAssetsAssignmentResult.Sequence     = _Item.Sequence;
                    _MasterAssetsAssignmentResult.IsActive     = _Item.IsActive;
                    _MasterAssetsAssignmentResult.ActiveColor  = "green";
                    _MasterAssetsAssignmentResult.ActiveIcon   = "glyphicon glyphicon-ok";
                    _MasterAssetsAssignmentResult.EnterById    = _Item.EnterById;
                    _MasterAssetsAssignmentResult.EnterDate    = _Item.EnterDate;
                    _MasterAssetsAssignmentResult.ModifiedById = _Item.ModifiedById;
                    _MasterAssetsAssignmentResult.ModifiedDate = _Item.ModifiedDate;

                    if (_MasterAssetsAssignmentResult.IsActive == false)
                    {
                        _MasterAssetsAssignmentResult.ActiveColor = "red";
                        _MasterAssetsAssignmentResult.ActiveIcon  = "glyphicon glyphicon-remove";
                    }

                    _MasterAssetsAssignmentResult.MasterProductChildId = _Item.MasterProductChildId;
                    _MasterAssetsAssignmentResult.MasterProductId      = _Item.MasterProductId;
                    //_MasterAssetsAssignmentResult.ASMasterProducts = _Item.ASMasterProducts;
                    _MasterAssetsAssignmentResult.ProductChildSKU        = _Item.ProductChildSKU;
                    _MasterAssetsAssignmentResult.ProductChildTitle      = _Item.ProductChildTitle;
                    _MasterAssetsAssignmentResult.ManufacturerPartNumber = _Item.ManufacturerPartNumber;
                    //_MasterAssetsAssignmentResult.ASMasterProductSizes = _Item.ASMasterProductSizes;
                    _MasterAssetsAssignmentResult.PurchaseDate                 = _Item.PurchaseDate;
                    _MasterAssetsAssignmentResult.PurchasePrice                = _Item.PurchasePrice;
                    _MasterAssetsAssignmentResult.DepreciatePrice              = _Item.DepreciatePrice;
                    _MasterAssetsAssignmentResult.MasterVendorId               = _Item.MasterVendorId;
                    _MasterAssetsAssignmentResult.IsDeadAssets                 = _Item.IsDeadAssets;
                    _MasterAssetsAssignmentResult.IsTimeToSaleProduct          = _Item.IsTimeToSaleProduct;
                    _MasterAssetsAssignmentResult.IsSaleProduct                = _Item.IsSaleProduct;
                    _MasterAssetsAssignmentResult.SaleDate                     = _Item.SaleDate;
                    _MasterAssetsAssignmentResult.SalePrice                    = _Item.SalePrice;
                    _MasterAssetsAssignmentResult.ProductQty                   = _Item.ProductQty;
                    _MasterAssetsAssignmentResult.ProductQtyUnit               = _Item.ProductQtyUnit;
                    _MasterAssetsAssignmentResult.NumberOfItemIncludeInProduct = _Item.NumberOfItemIncludeInProduct;
                    _MasterAssetsAssignmentResult.ItemPackageQuantity          = _Item.ItemPackageQuantity;
                    _MasterAssetsAssignmentResult.IterationOfWarranty          = _Item.IterationOfWarranty;
                    _MasterAssetsAssignmentResult.WarrantyStartDate            = _Item.WarrantyStartDate;
                    _MasterAssetsAssignmentResult.WarrantyExpiryDate           = _Item.WarrantyExpiryDate;
                    _MasterAssetsAssignmentResult.MasterBranchId               = _Item.MasterBranchId;
                    _MasterAssetsAssignmentResult.MasterEmployeeId             = _Item.MasterEmployeeId;

                    _MasterAssetsAssignmentResult.ProductTitle         = _Item.ProductTitle;
                    _MasterAssetsAssignmentResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterAssetsAssignmentResult.BrandTitle           = _Item.BrandTitle;
                    _MasterAssetsAssignmentResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterAssetsAssignmentResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterAssetsAssignmentResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterAssetsAssignmentResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterAssetsAssignmentResult.ProductSKU           = _Item.ProductSKU;
                    _MasterAssetsAssignmentResult.ProductModel         = _Item.ProductModel;
                    _MasterAssetsAssignmentResult.Manufacturer         = _Item.Manufacturer;
                    _MasterAssetsAssignmentResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterAssetsAssignmentResult.ReorderLevel         = _Item.ReorderLevel;
                }
                return(_MasterAssetsAssignmentResult);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public IEnumerable <MasterAssetsAssignmentResult> GetAllASMasterAssetsAssignment(long MasterEmployeeId)
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId
                             join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId
                             where MAA.MasterEmployeeId == MasterEmployeeId
                             select new
                {
                    MPC.MasterProductChildId,
                    MPC.MasterProductId,
                    MPC.ProductChildSKU,
                    MPC.ProductChildTitle,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchaseDate,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.MasterVendorId,
                    MPC.IsDeadAssets,
                    MPC.IsTimeToSaleProduct,
                    MPC.IsSaleProduct,
                    MPC.SaleDate,
                    MPC.SalePrice,
                    MPC.ProductQty,
                    MPC.ProductQtyUnit,
                    MPC.NumberOfItemIncludeInProduct,
                    MPC.ItemPackageQuantity,
                    MPC.IterationOfWarranty,
                    MPC.WarrantyStartDate,
                    MPC.WarrantyExpiryDate,
                    MPC.MasterBranchId,

                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    CA.MasterCategoryId,
                    CA.CategoryTitle,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.ProductModel,
                    MP.Manufacturer,


                    MAA.MasterAssetsAssignmentId,
                    MAA.AssetsAssignmentDate,
                    MAA.ASMasterProductChilds,
                    MAA.MasterEmployeeId,
                    MAA.IsAssetsDeAssign,
                    MAA.AssetsDeAssignmentDate,
                    MAA.DeAssignReason,
                    MAA.MasterLocationId,
                    MAA.Sequence,
                    MAA.IsActive,
                    MAA.EnterById,
                    MAA.EnterDate,
                    MAA.ModifiedById,
                    MAA.ModifiedDate,
                });

                List <MasterAssetsAssignmentResult> objMasterAssetsAssignmentResultList = new List <MasterAssetsAssignmentResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _MasterAssetsAssignmentResult = new MasterAssetsAssignmentResult();


                    _MasterAssetsAssignmentResult.MasterAssetsAssignmentId = _Item.MasterAssetsAssignmentId;
                    _MasterAssetsAssignmentResult.AssetsAssignmentDate     = _Item.AssetsAssignmentDate;
                    _MasterAssetsAssignmentResult.MasterEmployeeId         = _Item.MasterEmployeeId;
                    _MasterAssetsAssignmentResult.IsAssetsDeAssign         = _Item.IsAssetsDeAssign;
                    _MasterAssetsAssignmentResult.AssetsDeAssignmentDate   = _Item.AssetsDeAssignmentDate;
                    _MasterAssetsAssignmentResult.DeAssignReason           = _Item.DeAssignReason;
                    _MasterAssetsAssignmentResult.MasterLocationId         = _Item.MasterLocationId;
                    _MasterAssetsAssignmentResult.Sequence     = _Item.Sequence;
                    _MasterAssetsAssignmentResult.IsActive     = _Item.IsActive;
                    _MasterAssetsAssignmentResult.ActiveColor  = "green";
                    _MasterAssetsAssignmentResult.ActiveIcon   = "glyphicon glyphicon-ok";
                    _MasterAssetsAssignmentResult.EnterById    = _Item.EnterById;
                    _MasterAssetsAssignmentResult.EnterDate    = _Item.EnterDate;
                    _MasterAssetsAssignmentResult.ModifiedById = _Item.ModifiedById;
                    _MasterAssetsAssignmentResult.ModifiedDate = _Item.ModifiedDate;

                    if (_MasterAssetsAssignmentResult.IsActive == false)
                    {
                        _MasterAssetsAssignmentResult.ActiveColor = "red";
                        _MasterAssetsAssignmentResult.ActiveIcon  = "glyphicon glyphicon-remove";
                    }

                    _MasterAssetsAssignmentResult.MasterProductChildId = _Item.MasterProductChildId;
                    _MasterAssetsAssignmentResult.MasterProductId      = _Item.MasterProductId;
                    //_MasterAssetsAssignmentResult.ASMasterProducts = _Item.ASMasterProducts;
                    _MasterAssetsAssignmentResult.ProductChildSKU        = _Item.ProductChildSKU;
                    _MasterAssetsAssignmentResult.ProductChildTitle      = _Item.ProductChildTitle;
                    _MasterAssetsAssignmentResult.ManufacturerPartNumber = _Item.ManufacturerPartNumber;
                    //_MasterAssetsAssignmentResult.ASMasterProductSizes = _Item.ASMasterProductSizes;
                    _MasterAssetsAssignmentResult.PurchaseDate                 = _Item.PurchaseDate;
                    _MasterAssetsAssignmentResult.PurchasePrice                = _Item.PurchasePrice;
                    _MasterAssetsAssignmentResult.DepreciatePrice              = _Item.DepreciatePrice;
                    _MasterAssetsAssignmentResult.MasterVendorId               = _Item.MasterVendorId;
                    _MasterAssetsAssignmentResult.IsDeadAssets                 = _Item.IsDeadAssets;
                    _MasterAssetsAssignmentResult.IsTimeToSaleProduct          = _Item.IsTimeToSaleProduct;
                    _MasterAssetsAssignmentResult.IsSaleProduct                = _Item.IsSaleProduct;
                    _MasterAssetsAssignmentResult.SaleDate                     = _Item.SaleDate;
                    _MasterAssetsAssignmentResult.SalePrice                    = _Item.SalePrice;
                    _MasterAssetsAssignmentResult.ProductQty                   = _Item.ProductQty;
                    _MasterAssetsAssignmentResult.ProductQtyUnit               = _Item.ProductQtyUnit;
                    _MasterAssetsAssignmentResult.NumberOfItemIncludeInProduct = _Item.NumberOfItemIncludeInProduct;
                    _MasterAssetsAssignmentResult.ItemPackageQuantity          = _Item.ItemPackageQuantity;
                    _MasterAssetsAssignmentResult.IterationOfWarranty          = _Item.IterationOfWarranty;
                    _MasterAssetsAssignmentResult.WarrantyStartDate            = _Item.WarrantyStartDate;
                    _MasterAssetsAssignmentResult.WarrantyExpiryDate           = _Item.WarrantyExpiryDate;
                    _MasterAssetsAssignmentResult.MasterBranchId               = _Item.MasterBranchId;
                    _MasterAssetsAssignmentResult.MasterEmployeeId             = _Item.MasterEmployeeId;
                    _MasterAssetsAssignmentResult.EmployeeName                 = "";
                    _MasterAssetsAssignmentResult.ProductTitle                 = _Item.ProductTitle;
                    _MasterAssetsAssignmentResult.MasterBrandId                = _Item.MasterBrandId;
                    _MasterAssetsAssignmentResult.BrandTitle                   = _Item.BrandTitle;
                    _MasterAssetsAssignmentResult.MasterSubCategoryId          = _Item.MasterSubCategoryId;
                    _MasterAssetsAssignmentResult.SubCategoryTitle             = _Item.SubCategoryTitle;
                    _MasterAssetsAssignmentResult.MasterCategoryId             = _Item.MasterCategoryId;
                    _MasterAssetsAssignmentResult.CategoryTitle                = _Item.CategoryTitle;
                    _MasterAssetsAssignmentResult.ProductSKU                   = _Item.ProductSKU;
                    _MasterAssetsAssignmentResult.ProductModel                 = _Item.ProductModel;
                    _MasterAssetsAssignmentResult.Manufacturer                 = _Item.Manufacturer;
                    _MasterAssetsAssignmentResult.DepreciatePercentage         = _Item.DepreciatePercentage;
                    _MasterAssetsAssignmentResult.ReorderLevel                 = _Item.ReorderLevel;

                    objMasterAssetsAssignmentResultList.Add(_MasterAssetsAssignmentResult);
                }
                return(objMasterAssetsAssignmentResultList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }