public IHttpActionResult PostEnrollmentOfficeConfig(EnrollmentOfficeConfigDTO oDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = _EnrollmentOfficeConfigService.SaveEnrollmentOfficeConfig(oDto);

            if (result == -1)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
        /// <summary>
        /// This method is used to save and update the Enrollment Affiliate Configuration Detail
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int SaveEnrollmentOfficeConfig(EnrollmentOfficeConfigDTO dto)
        {
            // int entityState = 0;

            EnrollmentOfficeConfiguration model = new EnrollmentOfficeConfiguration();

            if (dto != null)
            {
                Guid Id, UserId, CustomerId;
                int  entityState = (int)System.Data.Entity.EntityState.Added;
                if (!Guid.TryParse(dto.CustomerId.ToString(), out CustomerId))
                {
                    return(-1);
                }
                if (!Guid.TryParse(dto.UserId.ToString(), out UserId))
                {
                    return(-1);
                }
                if (dto.Id != null)
                {
                    if (!Guid.TryParse(dto.Id.ToString(), out Id))
                    {
                        return(-1);
                    }

                    entityState = (int)System.Data.Entity.EntityState.Modified;

                    if (Id == Guid.Empty)
                    {
                        Id       = Guid.NewGuid();
                        model.Id = Id;
                    }
                }
                else
                {
                    Id       = Guid.NewGuid();
                    model.Id = Id;
                }

                if (entityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    model = db.EnrollmentOfficeConfigurations.Where(a => a.Id == dto.Id).FirstOrDefault();
                    if (model == null)
                    {
                        return(-1);
                    }
                }
                model.CustomerId = CustomerId;
                model.IsMainSiteTransmitTaxReturn = dto.IsMainSiteTransmitTaxReturn;
                model.NoofComputers        = dto.NoofComputers;
                model.NoofTaxProfessionals = dto.NoofTaxProfessionals;
                model.NoofTaxProfessionals = dto.NoofTaxProfessionals;
                model.PreferredLanguage    = dto.PreferredLanguage;
                model.IsSoftwareOnNetwork  = dto.IsSoftwareOnNetwork;
                model.StatusCode           = EMPConstants.Active;
                model.LastUpdatedBy        = dto.UserId ?? Guid.Empty;
                model.LastUpdatedDate      = System.DateTime.Now;

                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    model.CreatedBy   = dto.UserId ?? Guid.Empty;
                    model.CreatedDate = System.DateTime.Now;
                    db.EnrollmentOfficeConfigurations.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                }

                var custInfo = db.emp_CustomerInformation.Where(x => x.Id == CustomerId).FirstOrDefault();
                if (custInfo.EntityId == (int)EMPConstants.Entity.MO || custInfo.EntityId == (int)EMPConstants.Entity.SVB)
                {
                    var accountconfig = db.MainOfficeConfigurations.Where(x => x.emp_CustomerInformation_ID == CustomerId && x.StatusCode == EMPConstants.Active).FirstOrDefault();
                    if (accountconfig != null)
                    {
                        accountconfig.ComputerswillruninSoftware   = dto.NoofComputers ?? 0;
                        accountconfig.IsSoftwarebeInstalledNetwork = dto.IsSoftwareOnNetwork ?? false;
                        accountconfig.LastUpdatedBy            = dto.UserId ?? Guid.Empty;
                        accountconfig.LastUpdatedDate          = DateTime.Now;
                        accountconfig.PreferredSupportLanguage = dto.PreferredLanguage ?? 0;
                        accountconfig.TaxProfessionals         = dto.NoofTaxProfessionals ?? 0;
                    }
                }
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(1);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "EnrollmentOfficeConfigService/SaveEnrollmentOfficeConfig", Guid.Empty);
                return(-1);
            }
        }