public LabDetailModel GetById(Guid id)
        {
            try
            {
                LabDetailModel model = new LabDetailModel();
                using (var db = new HMSEntities())
                {
                    LabDetail entity = db.LabDetails.Find(id);
                    if (entity != null)
                    {
                        model.Id              = entity.Id;
                        model.Name            = entity.Name;
                        model.PathelogistName = entity.PathelogistName;
                        model.Address         = entity.Address;
                        model.PhoneNumber     = entity.PhoneNumber;
                        model.IsInHouse       = entity.IsInHouse;
                        model.IsActive        = entity.IsActive;
                        model.IsDeleted       = entity.IsDeleted;
                        model.CreatedOn       = entity.CreatedOn;
                        model.CreatedBy       = entity.CreatedBy;
                        model.ModifiedOn      = entity.ModifiedOn;
                        model.ModifiedBy      = entity.ModifiedBy;
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool Update(LabDetailModel model)
        {
            try
            {
                bool isSaved = false;

                if (!IsExist(model))
                {
                    using (var db = new HMSEntities())
                    {
                        //UpdateAllSequence(model.Id, model.Sequence.Value, model.PerentId);
                        LabDetail entity = db.LabDetails.Find(model.Id);
                        entity.Name            = model.Name;
                        entity.PathelogistName = model.PathelogistName;
                        entity.Address         = model.Address;
                        entity.PhoneNumber     = model.PhoneNumber;
                        entity.IsInHouse       = model.IsInHouse.HasValue ? model.IsInHouse.Value : false;
                        entity.ModifiedOn      = DateTime.Now;
                        entity.ModifiedBy      = UserDetailSession.Id;

                        db.SaveChanges();

                        isSaved = true;
                    }
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public LabDetailModel GetByName(string name)
        {
            try
            {
                LabDetailModel model = new LabDetailModel();
                using (var db = new HMSEntities())
                {
                    LabDetail entity = db.LabDetails.FirstOrDefault(t => t.Name == name);
                    if (entity != null)
                    {
                        model.Id              = entity.Id;
                        model.Name            = entity.Name;
                        model.PathelogistName = entity.PathelogistName;
                        model.Address         = entity.Address;
                        model.PhoneNumber     = entity.PhoneNumber;
                        model.IsActive        = entity.IsActive;
                        model.IsDeleted       = entity.IsDeleted;
                        model.CreatedOn       = entity.CreatedOn;
                        model.CreatedBy       = entity.CreatedBy;
                        model.ModifiedOn      = entity.ModifiedOn;
                        model.ModifiedBy      = entity.ModifiedBy;
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool Create(LabDetailModel model)
        {
            try
            {
                bool isSaved = false;

                if (!IsExist(model))
                {
                    using (var db = new HMSEntities())
                    {
                        LabDetail entity = new LabDetail();

                        entity.Name            = model.Name;
                        entity.PathelogistName = model.PathelogistName;
                        entity.Address         = model.Address;
                        entity.PhoneNumber     = model.PhoneNumber;
                        entity.IsInHouse       = model.IsInHouse.HasValue ? model.IsInHouse.Value : false;
                        entity.IsActive        = true;
                        entity.IsDeleted       = false;
                        entity.CreatedOn       = DateTime.Now;
                        entity.CreatedBy       = UserDetailSession.Id;

                        db.LabDetails.Add(entity);
                        db.SaveChanges();

                        isSaved = true;
                    }
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }