Esempio n. 1
0
        private bool InsertOfficeToDb(DMOffice Office, Guid userGuid)
        {
            var entity = MapOfficeToCoreOffice(Office, userGuid);

            _officeService.Add(entity);
            return(true);
        }
Esempio n. 2
0
 private Office MapOfficeToCoreOffice(DMOffice office, Guid userGuid)
 {
     officeEntity                      = new Office();
     officeEntity.OfficeGuid           = Guid.NewGuid();
     officeEntity.OfficeName           = office.OfficeName;
     officeEntity.OfficeCode           = office.OfficeCode;
     officeEntity.PhysicalAddress      = office.PhysicalAddress;
     officeEntity.PhysicalAddressLine1 = office.PhysicalAddress1;
     officeEntity.PhysicalCountryId    = office.PhysicalCountryGuid;
     officeEntity.PhysicalStateId      = office.PhysicalStateGuid;
     officeEntity.PhysicalCity         = office.PhysicalCity;
     officeEntity.PhysicalZipCode      = office.PhysicalZipCode;
     officeEntity.MailingAddress       = office.MailingAddress;
     officeEntity.MailingAddressLine1  = office.MailingAddress1;
     officeEntity.MailingCountryId     = office.MailingCountryGuid;
     officeEntity.MailingStateId       = office.MailingStateGuid;
     officeEntity.MailingCity          = office.MailingCity;
     officeEntity.MailingZipCode       = office.MailingZipCode;
     officeEntity.Phone                = office.Phone;
     officeEntity.Fax                  = office.Fax;
     officeEntity.CreatedOn            = DateTime.UtcNow;
     officeEntity.IsActive             = true;
     officeEntity.IsDeleted            = false;
     officeEntity.CreatedBy            = userGuid;
     officeEntity.UpdatedBy            = userGuid;
     officeEntity.UpdatedOn            = DateTime.UtcNow;
     if (office.OperationManagerGuid != Guid.Empty)
     {
         officeEntity.OperationManagerGuid = office.OperationManagerGuid;
     }
     return(officeEntity);
 }
Esempio n. 3
0
        private DMOffice CheckDuplicateOffice(DMOffice Office)
        {
            var r = _officeService.GetOfficeByCode(Office.OfficeCode);

            if (r != null)
            {
                Office.Reason = "Duplicate code";
            }
            return(Office);
        }
Esempio n. 4
0
        private DMOffice EnableDisableDeleteOffice(DMOffice Office, Guid officeGuid)
        {
            var action = Office.Action.ToLower();

            if (action == ImportAction.Delete.ToString().ToLower())
            {
                var result = DeleteOffice(officeGuid);
                Office.Reason = "Deleted Successfully";
            }
            else if (action == ImportAction.Enable.ToString().ToLower())
            {
                var result = EnableDisableOffice(true, officeGuid);
                Office.Reason = "Enable Successfully";
            }
            else
            {
                var result = EnableDisableOffice(false, officeGuid);
                Office.Reason = "Disable Successfully";
            }

            Office.ImportStatus = Core.Entities.ImportStatus.Success.ToString();
            return(Office);
        }
Esempio n. 5
0
        private DMOffice DataValidation(DMOffice office)
        {
            office.IsValid = true;
            var customerObject = MapperHelper.CreateDataObjectFromObject(office);

            foreach (var item in customerObject)
            {
                switch (item.Key)
                {
                case "PhysicalCountry":
                    var physicalCountry = _countryService.GetCountryByCountryName(office.PhysicalCountry);
                    if (physicalCountry == null)
                    {
                        office.IsPartialValid = false;
                        office.Reason        += "Physical country not found";
                    }
                    break;

                case "PhysicalState":
                    var physicalState = _stateService.GetStateByStateName(office.PhysicalState);
                    if (physicalState == null)
                    {
                        office.IsPartialValid = false;
                        office.Reason        += "Physical state not found";
                    }
                    break;

                case "MailingCountry":
                    var mailingCountry = _countryService.GetCountryByCountryName(office.MailingCountry);
                    if (mailingCountry == null)
                    {
                        office.IsPartialValid = false;
                        office.Reason        += "Mailing country not found";
                    }
                    else
                    {
                        office.MailingCountryGuid = mailingCountry.CountryId;
                    }
                    break;

                case "MailingState":
                    var mailingState = _stateService.GetStateByStateName(office.MailingState);
                    if (mailingState == null)
                    {
                        office.IsPartialValid = false;
                        office.Reason        += "Mailing state not found";
                    }
                    else
                    {
                        office.MailingStateGuid = mailingState.StateId;
                    }
                    break;

                case "PhysicalCity":
                    if (string.IsNullOrEmpty(office.PhysicalCity))
                    {
                        office.IsPartialValid = false;
                        office.Reason         = "PhysicalCity is empty";
                    }
                    break;

                case "PhysicalAddress":
                    if (string.IsNullOrEmpty(office.PhysicalAddress))
                    {
                        office.IsPartialValid = false;
                        office.Reason         = "PhysicalAddress is empty";
                    }
                    break;

                case "":
                    if (string.IsNullOrEmpty(office.Phone))
                    {
                        office.IsPartialValid = false;
                        office.Reason         = "Phone is empty";
                    }
                    break;
                }
            }
            return(office);
        }