public JsonResult CreateService(int serviceId, string code, string desc, bool status)
        {
            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
            log.Debug("Start: " + methodBase.Name);
            try
            {
                Int32 returnValue = -2;
                int checkSession = UserLogin.AuthenticateRequest();
                int createdBy = Convert.ToInt32(Session["UserID"]);

                if (checkSession == 0)
                {
                    return Json(returnValue);
                }
                else
                {
                    var data = new Service
                    {
                        Id = serviceId,
                        Code = code,
                        Description = desc,
                        Status = status,
                        CreatedBy = createdBy
                    };

                    int result = data.InsertService();
                    return Json(result);
                }
            }
            catch (Exception ex)
            {
                log.Error("Error: " + ex);
                return Json("");
            }
            finally
            {
                log.Debug("End: " + methodBase.Name);
            }
        }
Example #2
0
        /// <summary>
        /// Description  : To Get Service Which you want to Edit
        /// Created By   : Anji
        /// Created Date : 03 May 2014
        /// Modified By  :
        /// Modified Date:
        /// </summary>
        /// <param name="serviceId">pass the Service id which Service details you wont </param>
        /// <returns>it will give service </returns>
        public static Service GetServiceById(int? id)
        {
            var services = new Service();

            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
            log.Debug("Start: " + methodBase.Name);
            try
            {
                SqlParameter[] sqlParams = new SqlParameter[1];
                sqlParams[0] = new SqlParameter("@id", id);
                var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "SpGetServiceById", sqlParams);

                while (reader.Read())
                {
                    services.FetchService(services, new SafeDataReader(reader));
                }
                return services;
            }
            catch (Exception ex)
            {
                log.Error("Error: " + ex);
                return services;
            }
            finally
            {
                log.Debug("End: " + methodBase.Name);
            }
        }
Example #3
0
 private Service FetchService(Service service, SafeDataReader dr)
 {
     service.Id = dr.GetInt32("ID");
     service.Code = dr.GetString("Code");
     service.Description = dr.GetString("Description");
     service.Status = dr.GetBoolean("Status");
     return service;
 }
Example #4
0
        /// <summary>
        /// Description  : To Show all the Services in View
        /// Created By   : Anji
        /// Created Date : 03 May 2014
        /// Modified By  :
        /// Modified Date:
        /// </summary>
        /// <returns>it will give all the Service details available in database</returns>
        public static ServiceInfo GetAllServices(int startPage, int resultPerPage, string code, int status, string OrderBy)
        {
            var data = new ServiceInfo();

            System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
            System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
            log.Debug("Start: " + methodBase.Name);
            try
            {
                SqlParameter[] sqlParams = new SqlParameter[5];
                sqlParams[0] = new SqlParameter("@startPage", startPage);
                sqlParams[1] = new SqlParameter("@resultPerPage", resultPerPage);
                sqlParams[2] = new SqlParameter("@code", code);
                sqlParams[3] = new SqlParameter("@status", status);
                sqlParams[4] = new SqlParameter("@OrderBy", OrderBy);

                var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "[SpGetAllMServices]", sqlParams);
                var safe = new SafeDataReader(reader);
                while (reader.Read())
                {
                    var service = new Service();
                    service.FetchService(service, safe);
                    data.ServiceList.Add(service);
                    data.ServiceCount = Convert.ToInt32(reader["serviceCount"]);
                }
                return data;
            }
            catch (Exception ex)
            {
                log.Error("Error: " + ex);
                return data;
            }
            finally
            {
                log.Debug("End: " + methodBase.Name);
            }
        }