public static void AddNewConsumerRow(TestConsumerModel consumer)
        {
            aeghealthEntities context      = new aeghealthEntities();
            tblConsumer       consumerdata = new tblConsumer()
            {
                ConsumerID         = consumer.ConsumerID,
                GroupID            = consumer.GroupID,
                LN                 = consumer.LN,
                FN                 = consumer.FN,
                MI                 = consumer.MI,
                LNSoundex          = consumer.LNSoundex,
                MlAddr1            = consumer.MlAddr1,
                MlCity             = consumer.MlCity,
                MlState            = consumer.MlState,
                MlZip              = consumer.MlZip,
                AcTel              = consumer.AcTel,
                Tel                = consumer.Tel,
                C_SSN              = consumer.C_SSN,
                DOB                = consumer.DOB,
                bChildren          = consumer.bChildren,
                MaritalStatusID    = consumer.MaritalStatusID,
                bFamilyIns         = consumer.bFamilyIns,
                bHasDr             = consumer.bHasDr,
                DrLocCit           = consumer.DrLocCit,
                DrLocSt            = consumer.DrLocSt,
                Gender             = consumer.Gender,
                EmploymentStatusID = consumer.EmploymentStatusID,
                CreatedByID        = consumer.CreatedByID
            };

            context.tblConsumers.Add(consumerdata);
            context.SaveChanges();
        }
        public int SaveProfile([FromBody] Profile obj)
        {
            if (obj != null)
            {
                if (obj.ID > 0)
                {
                    var loginObj = db.tblLogins.Where(x => x.ID == obj.ID).ToList();
                    if (loginObj != null && loginObj.Count > 0)
                    {
                        loginObj[0].Password       = obj.NewPassword;
                        loginObj[0].EmailId        = !string.IsNullOrEmpty(obj.Email) ? obj.Email : string.Empty;
                        loginObj[0].Address        = !string.IsNullOrEmpty(obj.Address) ? obj.Address : string.Empty;
                        loginObj[0].City           = !string.IsNullOrEmpty(obj.City) ? obj.City : string.Empty;
                        loginObj[0].ZipCode        = obj.ZipCode;
                        loginObj[0].ProfilePicture = ConvertBase64StringToByteArray(obj.ProfilePicture);
                        loginObj[0].State          = obj.State;

                        db.Entry(loginObj[0]).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
                else
                {
                    tblLogin loginObj = new tblLogin();
                    loginObj.UserName       = obj.UserName;
                    loginObj.Password       = obj.NewPassword;
                    loginObj.EmailId        = obj.Email;
                    loginObj.Address        = obj.Address;
                    loginObj.City           = obj.City;
                    loginObj.State          = obj.State;
                    loginObj.ZipCode        = obj.ZipCode;
                    loginObj.IsAdmin        = obj.IsAdmin;
                    loginObj.ProfilePicture = ConvertBase64StringToByteArray(obj.ProfilePicture);

                    db.tblLogins.Add(loginObj);
                    int loginID = db.SaveChanges();
                    if (loginID > 0)
                    {
                        tblConsumer consumerObj = new tblConsumer();
                        consumerObj.ConsumerNo   = obj.ConsumerNo;
                        consumerObj.ConsumerName = obj.UserName;
                        consumerObj.RegionCode   = obj.RegionCode;
                        consumerObj.Login_ID     = loginObj.ID;

                        db.tblConsumers.Add(consumerObj);
                        db.SaveChanges();
                    }

                    return(loginObj.ID);
                }
            }

            return(obj.ID);
        }