Esempio n. 1
0
        public int DeleteTransportationDetails(TransportationDetails objTransportation)
        {
            int id = 0;

            try
            {
                using (var conn = new SqlConnection(ContexDetails.Connectiondetails()))
                {
                    conn.Open();
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "sp_DeleteTransportation";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@Id", objTransportation.Id < 0 ? 0 : objTransportation.Id);
                        cmd.Parameters.AddWithValue("@UserId", objTransportation.CreatedBy);
                        cmd.ExecuteNonQuery();
                        id = 1;
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(id);
        }
Esempio n. 2
0
        public int AddUpdateTransportationDetails(TransportationDetails objuser)
        {
            int id = 0;

            try
            {
                using (var conn = new SqlConnection(ContexDetails.Connectiondetails()))
                {
                    conn.Open();
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "sp_AddUpdateTransportationDetails";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@Id", objuser.Id < 0 ? 0 : objuser.Id);
                        cmd.Parameters.AddWithValue("@OwnerName", objuser.OwnerName);
                        cmd.Parameters.AddWithValue("@TransportationType", objuser.TransportationType);
                        cmd.Parameters.AddWithValue("@VehicleNumber", objuser.VehicleNumber);
                        cmd.Parameters.AddWithValue("@CreatedBy", objuser.CreatedBy);
                        id = cmd.ExecuteNonQuery();
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(id);
        }
Esempio n. 3
0
        public UserInfo GetTransportationDetails(TransportationDetails transportationDetails)
        {
            IUserDetails _repository = new UserDetails();
            IList <TransportationDetails> response = new List <TransportationDetails>();

            response = _repository.GetTransportationDetailsByUser(transportationDetails.CreatedBy);
            UserInfo userDetailsInfo = new UserInfo();

            userDetailsInfo.TransportationLists = response;
            return(userDetailsInfo);
        }
Esempio n. 4
0
        public ResponseModel AddUpdateTransportationDetails(TransportationDetails request)
        {
            IUserDetails _repository = new UserDetails();
            int          response    = 0;

            response = _repository.AddUpdateTransportationDetails(request);
            string        Status = "0";
            ResponseModel model  = new ResponseModel();

            if (response == 1)
            {
                model.Status  = "1";
                model.Message = "New transportation details added/updated successfully";
            }
            else
            {
                model.Status = "0";
            }
            return(model);
        }
Esempio n. 5
0
        public IList <TransportationDetails> GetTransportationDetailsByUser(int UserId)
        {
            IList <TransportationDetails> transportationDetails = new List <TransportationDetails>();

            try
            {
                using (var conn = new SqlConnection(ContexDetails.Connectiondetails()))
                {
                    conn.Open();
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "sp_GetTransportationDetailsByUser";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@UserId", UserId);
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                TransportationDetails model = new TransportationDetails();
                                model.Id                 = Convert.ToInt32(reader["Id"]);
                                model.OwnerName          = Convert.ToString(reader["OwnerName"]);
                                model.TransportationType = Convert.ToString(reader["TransportationType"]);
                                model.VehicleNumber      = Convert.ToString(reader["VehicleNumber"]);
                                model.CreatedBy          = Convert.ToInt32(reader["CreatedBy"]);
                                transportationDetails.Add(model);
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(transportationDetails);
        }