Example #1
0
        public List <CompanyBusinessSpecialityModel> SaveCompanyBusinessSpeciality(CompanyBusinessSpecialityModel model)
        {
            List <CompanyBusinessSpecialityModel> companyBusinessSpecialityList = new List <CompanyBusinessSpecialityModel>();

            try
            {
                _sqlConnService.OpenConnection();
                SqlCommand cmd = new SqlCommand("SP_SaveCompanyBusinessSpeciality", _sqlConnService.CreateConnection());
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ID", model.ID);
                cmd.Parameters.AddWithValue("@Code", model.Code);
                cmd.Parameters.AddWithValue("@Name_" + model.CurrentCulture, model.Name);
                cmd.Parameters.AddWithValue("@IsActive", model.IsActive);
                cmd.Parameters.AddWithValue("@CreatedBy", model.CurrentUserID);
                cmd.Parameters.AddWithValue("@CultureId", model.CurrentCulture);
                int a = cmd.ExecuteNonQuery();
                _sqlConnService.CloseConnection();
                if (a > 0)
                {
                    companyBusinessSpecialityList = GetAllCompanyBusinessSpecialityList(model);
                }
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "CompanyBusinessSpeciality", message);
                throw new Exception(ex.Message);
            }
            return(companyBusinessSpecialityList);
        }
 public HttpResponseMessage Delete(CompanyBusinessSpecialityModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var companyBusinessSpecialityList = _companyBusinessSpecialityService.DeleteCompanyBusinessSpeciality(model);
             if (companyBusinessSpecialityList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, companyBusinessSpecialityList));
             }
             else
             {
                 string message = "Not deleted successfully";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
 public HttpResponseMessage GetBusinessSpecialityModels(CompanyBusinessSpecialityModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var companyBusinessSpecialityList = _companyBusinessSpecialityService.GetAllCompanyBusinessSpecialityList(model);
             if (companyBusinessSpecialityList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, companyBusinessSpecialityList));
             }
             else
             {
                 string message = "Error in getting Data";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
     }
 }
Example #4
0
        public List <CompanyBusinessSpecialityModel> GetAllCompanyBusinessSpecialityList(CompanyBusinessSpecialityModel model)
        {
            List <CompanyBusinessSpecialityModel> companyBusinessSpecialityList = new List <CompanyBusinessSpecialityModel>();
            CompanyBusinessSpecialityModel        companyBusinessSpecialityModel;

            try
            {
                _sqlConnService.OpenConnection();
                SqlCommand command = new SqlCommand("SP_GetAllCompanyBusinessSpeciality", _sqlConnService.CreateConnection());
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@CultureId", model.CurrentCulture);
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    companyBusinessSpecialityModel                = new CompanyBusinessSpecialityModel();
                    companyBusinessSpecialityModel.ID             = Guid.Parse(reader["ID"].ToString());
                    companyBusinessSpecialityModel.Code           = reader["Code"].ToString();
                    companyBusinessSpecialityModel.Name           = reader["Name"].ToString();
                    companyBusinessSpecialityModel.IsActive       = Convert.ToBoolean(reader["IsActive"].ToString());
                    companyBusinessSpecialityModel.CreatedDate    = Convert.ToDateTime(reader["CreatedDate"].ToString());
                    companyBusinessSpecialityModel.CreatedBy      = Convert.ToInt32(reader["CreatedBy"].ToString());
                    companyBusinessSpecialityModel.UpdatedDate    = Convert.ToDateTime(reader["UpdatedDate"].ToString());
                    companyBusinessSpecialityModel.UpdatedBy      = Convert.ToInt32(reader["UpdatedBy"].ToString());
                    companyBusinessSpecialityModel.CurrentUserID  = model.CurrentUserID;
                    companyBusinessSpecialityModel.CurrentCulture = model.CurrentCulture;
                    companyBusinessSpecialityList.Add(companyBusinessSpecialityModel);
                }
                _sqlConnService.CloseConnection();
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "CompanyBusinessSpeciality", message);
                throw new Exception(ex.Message);
            }
            return(companyBusinessSpecialityList);
        }