public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity)
        {
            BO.Log room   = (BO.Log)(object) entity;
            var    result = room.Validate(room);

            return(result);
        }
        public override T Convert <T, U>(U entity)
        {
            Log log = entity as Log;

            if (log == null)
            {
                return(default(T));
            }

            BO.Log logBO = new BO.Log();
            logBO.ID          = log.id;
            logBO.requestId   = log.RequestID;
            logBO.responseId  = log.ResponseID;
            logBO.ipaddress   = log.IpAddress;
            logBO.country     = log.Country;
            logBO.machinename = log.MachineName;
            logBO.userId      = log.UserID;
            logBO.requestUrl  = log.RequestURL;


            if (log.IsDeleted.HasValue)
            {
                logBO.IsDeleted = log.IsDeleted.Value;
            }
            if (log.UpdateByUserID.HasValue)
            {
                logBO.UpdateByUserID = log.UpdateByUserID.Value;
            }

            return((T)(object)logBO);
        }
 public override object Get(int id)
 {
     BO.Log acc_ = Convert <BO.Log, Log>(_context.Logs.Where(p => p.id == id && (p.IsDeleted == false || p.IsDeleted == null)).FirstOrDefault <Log>());
     if (acc_ == null)
     {
         return(new BO.ErrorObject {
             ErrorMessage = "No record found for this room.", errorObject = "", ErrorLevel = ErrorLevel.Error
         });
     }
     return((object)acc_);
 }
        public override object Delete <T>(T entity)
        {
            BO.Log logBO = entity as BO.Log;

            Log logDB = new Log();

            logDB.id = logBO.ID;
            _dbSet.Remove(_context.Logs.Single <Log>(p => p.id == logBO.ID));
            _context.SaveChanges();

            var res = (BO.GbObject)(object) entity;

            return(logDB);
        }
        public override object Save <T>(T entity)
        {
            BO.Log logBO = (BO.Log)(object) entity;

            Log logDB = new Log();

            #region Log
            logDB.id          = logBO.ID;
            logDB.RequestID   = logBO.requestId;
            logDB.ResponseID  = logBO.responseId;
            logDB.IpAddress   = logBO.ipaddress;
            logDB.Country     = logBO.country;
            logDB.MachineName = logBO.machinename;
            logDB.UserID      = logBO.userId;
            logDB.RequestURL  = logBO.requestUrl;
            logDB.IsDeleted   = logBO.IsDeleted.HasValue ? logBO.IsDeleted : false;
            #endregion

            if (logDB.id > 0)
            {
                //For Update Record

                Log log = _context.Logs.Where(p => p.id == logDB.id && (p.IsDeleted == false || p.IsDeleted == null)).FirstOrDefault <Log>();

                if (log != null)
                {
                    #region Log
                    log.id             = logBO.ID;
                    log.RequestID      = logBO.requestId == null ? log.RequestID : logBO.requestId;
                    log.ResponseID     = logBO.responseId == null ? log.ResponseID : logBO.responseId;
                    log.IpAddress      = logBO.ipaddress == null ? log.IpAddress : logBO.ipaddress;
                    log.Country        = logBO.country == null ? log.Country : logBO.country;
                    log.MachineName    = logBO.machinename == null ? log.MachineName : logBO.machinename;
                    log.UserID         = logBO.userId == null ? log.UserID : logBO.userId;
                    log.RequestURL     = logBO.requestUrl == null ? log.RequestURL : logBO.requestUrl;
                    log.IsDeleted      = logBO.IsDeleted == null ? logBO.IsDeleted : log.IsDeleted;
                    log.UpdateDate     = logBO.UpdateDate;
                    log.UpdateByUserID = logBO.UpdateByUserID;
                    #endregion

                    _context.Entry(log).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    return new BO.ErrorObject {
                               errorObject = "", ErrorMessage = "Please pass valid room details.", ErrorLevel = ErrorLevel.Error
                    }
                };
            }
            else
            {
                if (_context.Logs.Any(o => o.IpAddress == logBO.ipaddress))
                {
                    return(new BO.ErrorObject {
                        ErrorMessage = "Logs already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error
                    });
                }

                logDB.CreateDate     = logBO.CreateDate;
                logDB.CreateByUserID = logBO.CreateByUserID;
                _dbSet.Add(logDB);
            }
            _context.SaveChanges();

            var res = Convert <BO.Log, Log>(logDB);
            return((T)(object)res);
        }
        public override object Save <T>(T entity)
        {
            BO.Specialty specialtyBO = (BO.Specialty)(object) entity;

            Specialty speclityDB = new Specialty();

            #region Specialty
            speclityDB.id             = specialtyBO.ID;
            speclityDB.Name           = specialtyBO.Name;
            speclityDB.SpecialityCode = specialtyBO.SpecialityCode;
            speclityDB.IsUnitApply    = specialtyBO.IsUnitApply;
            speclityDB.IsDeleted      = specialtyBO.IsDeleted.HasValue ? specialtyBO.IsDeleted.Value : false;
            speclityDB.ColorCode      = specialtyBO.ColorCode;
            #endregion


            if (speclityDB.id > 0)
            {
                //Find Specialty By ID
                Specialty specialty = _context.Specialties.Where(p => p.id == speclityDB.id).FirstOrDefault <Specialty>();

                if (specialty != null)
                {
                    #region Specialty
                    specialty.id             = specialtyBO.ID;
                    specialty.Name           = specialtyBO.Name != null ? specialtyBO.Name : specialty.Name;
                    specialty.IsUnitApply    = specialtyBO.IsUnitApply != null ? specialtyBO.IsUnitApply : specialty.IsUnitApply;
                    specialty.SpecialityCode = specialtyBO.SpecialityCode != null ? specialtyBO.SpecialityCode : specialty.SpecialityCode;
                    specialty.IsDeleted      = specialtyBO.IsDeleted != null ? specialtyBO.IsDeleted : specialty.IsDeleted;
                    specialty.UpdateByUserID = specialtyBO.UpdateByUserID;
                    specialty.ColorCode      = specialtyBO.ColorCode != null ? specialtyBO.ColorCode : specialty.ColorCode;
                    #endregion

                    _context.Entry(specialty).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    return(new BO.ErrorObject {
                        ErrorMessage = "No record found for this Specialty.", errorObject = "", ErrorLevel = ErrorLevel.Error
                    });
                }
            }
            else
            {
                speclityDB.CreateByUserID = specialtyBO.CreateByUserID;

                _dbSet.Add(speclityDB);
            }
            _context.SaveChanges();

            BO.Log log = new BO.Log();

            using (LogRepository lg = new LogRepository(_context))
            {
                log.requestId   = "3";
                log.responseId  = "3";
                log.machinename = Utility.MachineName();
                //log.ipaddress = Utility.GetIpaddress().ToString();
                log.ipaddress  = "190.2.12.104";
                log.country    = "YY";
                log.userId     = 2;
                log.requestUrl = "www.ost.in";
                log.IsDeleted  = false;

                lg.Save(log);
            }



            var res = Convert <BO.Specialty, Specialty>(speclityDB);
            return((object)res);
        }