Пример #1
0
        public bool ActivateLicense(LicenseActivationDetail lad)
        {
            try
            {
                var catalog = _unitOfWork.GetRepository <CustomerCatalogGroup>().Single(x => x.CustomerCatalogGroupId == lad.CustomerCatalogGroupId);



                BusinessContact businessContact = new BusinessContact();
                businessContact.BusinessName = lad.BusinessName;
                businessContact.MobileNumber = lad.MobileNo;

                Contact contact = new Contact();
                contact.FirstName = lad.ContactPersonName;

                businessContact.ContactPerson = contact;

                Customer cus = new Customer();
                cus.BusinessContact = businessContact;
                cus.CustomerEmailId = lad.EmailId;
                cus.MobileNo        = lad.MobileNo;

                catalog.NumberofSystem = 1;
                catalog.Customer       = cus;
                LicenseRenewedDetail licenseRenewed = new LicenseRenewedDetail();
                licenseRenewed.CustomerCatalogGroupId = catalog.Id;
                licenseRenewed.RenewedDate            = System.DateTime.Now;
                licenseRenewed.ExpiryDate             = System.DateTime.Now.AddDays(10);

                _unitOfWork.GetRepository <LicenseRenewedDetail>().Add(licenseRenewed);

                catalog.RenewedDetailId = licenseRenewed.Id;

                _unitOfWork.GetRepository <BusinessContact>().Add(businessContact);
                _unitOfWork.GetRepository <Contact>().Add(contact);
                _unitOfWork.GetRepository <Customer>().Add(cus);

                _unitOfWork.GetRepository <CustomerCatalogGroup>().Update(catalog);

                //LicensedHardware licensedHardware = new LicensedHardware();
                //licensedHardware.HardwareId = lad.HardwareId;
                //licensedHardware.CustomerCatalogGroupId = catalog.Id;
                //licensedHardware.ActivatedDate = System.DateTime.Now;
                //_unitOfWork.GetRepository<LicensedHardware>().Add(licensedHardware);
                _unitOfWork.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(false);
            }
        }
Пример #2
0
        public int AddHardware(LicenseActivationDetail lad)
        {
            var catalog = _unitOfWork.GetRepository <CustomerCatalogGroup>().Single(x => x.CustomerCatalogGroupId == lad.CustomerCatalogGroupId);
            LicensedHardware licensedHardware = new LicensedHardware();

            licensedHardware.HardwareId             = lad.HardwareId;
            licensedHardware.CustomerCatalogGroupId = catalog.Id;
            licensedHardware.DeviceName             = lad.DeviceName;
            licensedHardware.DeviceType             = lad.DeviceType;
            licensedHardware.DeviceComment          = lad.DeviceComment;
            licensedHardware.MacAddress             = lad.MacAddress;
            licensedHardware.ActivatedDate          = System.DateTime.Now;
            _unitOfWork.GetRepository <LicensedHardware>().Add(licensedHardware);
            return(_unitOfWork.SaveChanges());
        }
Пример #3
0
        public async Task <ActionResult <LicenseDetail> > Activation([FromBody] LicenseActivationDetail licenseActivationDetail)
        {
            LicenseActivationDetail lad = licenseActivationDetail;

            if (!_Service.TryGetLicense(lad.CustomerCatalogGroupId, out var license))
            {
                return(NotFound());
            }
            var Hardware = _Service.GetLicensedHardwares().Where(x => x.CustomerCatalogGroupId == Guid.Parse(license.CustomerCatalogGroupId));
            var v        = Hardware.Where(x => x.HardwareId == licenseActivationDetail.HardwareId);

            if (v.Count() == 0)
            {
                if (Hardware.Count() > license.NumberofSystem)
                {
                    return(BadRequest());
                }
                else
                {
                    _Service.AddHardware(licenseActivationDetail);
                }
            }
            else
            {
                if (lad.CallType == Domain.Entity.ActivateCallType.CheckIn)
                {
                }
            }



            if (lad.CallType == Domain.Entity.ActivateCallType.FirstTime)
            {
                _Service.ActivateLicense(licenseActivationDetail);
            }

            //return CreatedAtAction(nameof(GetById), new { id = license.CustomerCatalogGroupId }, license);
            if (!_Service.TryGetLicense(lad.CustomerCatalogGroupId, out var Rlicense))
            {
                return(NotFound());
            }
            return(Ok(Rlicense));
        }