Ejemplo n.º 1
0
        public bool InsertAssignFieldOfficer(AddFieldOfficerDTO objFieldOfficer)
        {
            bool       res    = false;
            SqlCommand SqlCmd = new SqlCommand("spInsertFieldOfficerByCustomer");

            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Parameters.AddWithValue("@FieldOfficerId", objFieldOfficer.EmployeeId);
            SqlCmd.Parameters.AddWithValue("@CustomerId", objFieldOfficer.CustomerId);
            SqlCmd.Parameters.AddWithValue("@BranchId", objFieldOfficer.BranchId);
            SqlCmd.Parameters.AddWithValue("@CreatedBy", objFieldOfficer.CreatedBy);
            SqlCmd.Parameters.Add(new SqlParameter("@SiteId", SqlDbType.Int));
            foreach (var id in objFieldOfficer.Site)
            {
                if (SqlCmd.Connection != null)
                {
                    if (SqlCmd.Connection.State == ConnectionState.Closed)
                    {
                        SqlCmd.Connection.Open();
                    }
                }
                SqlCmd.Parameters["@SiteId"].Value = id.SiteId;
                int result = new DbLayer().ExecuteNonQuery(SqlCmd);
                if (result != Int32.MaxValue)
                {
                    res = true;
                }
            }
            return(res);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage CreateAssignFieldOfficer(AddFieldOfficerDTO assign)
        {
            HttpResponseMessage message;

            try
            {
                // AssignFieldOfficerDataAccessLayer _FieldOfficer = new AssignFieldOfficerDataAccessLayer();
                var dynObj = new { result = _FieldOfficer.InsertAssignFieldOfficer(assign) };
                message = Request.CreateResponse(HttpStatusCode.OK, dynObj);
            }
            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Something wrong. Try Again!" });

                ErrorLog.CreateErrorMessage(ex, "FieldOfficer", "CreateAssignFieldOfficer");
            }
            return(message);
        }